From 4edf9c5d7d425a511de85275e7f4c6e08ae76f29 Mon Sep 17 00:00:00 2001 From: Sean Cha Date: Fri, 6 May 2022 11:59:01 -0700 Subject: [PATCH 1/2] Added bbox info in save-pose output (JSON) file. --- .../deepstream_pose_estimation_app.cpp | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp b/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp index 01ba5f2..ad5cf49 100644 --- a/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp +++ b/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp @@ -969,9 +969,35 @@ void parse_25dpose_from_tensor_meta(NvDsInferTensorMeta *tensor_meta, fprintf(_pose_file, ", "); } fsetpos(_pose_file, &g_fp_25_pos); - fprintf(_pose_file, "]\n"); + fprintf(_pose_file, "],\n"); + + //---Save bounding box coordinates--- + { + float left, top, width, height; + if (strcmp(_tracker, "none")) { + left = obj_meta->tracker_bbox_info.org_bbox_coords.left; + top = obj_meta->tracker_bbox_info.org_bbox_coords.top; + width = obj_meta->tracker_bbox_info.org_bbox_coords.width; + height = obj_meta->tracker_bbox_info.org_bbox_coords.height; + } + else { + left = obj_meta->detector_bbox_info.org_bbox_coords.left; + top = obj_meta->detector_bbox_info.org_bbox_coords.top; + width = obj_meta->detector_bbox_info.org_bbox_coords.width; + height = obj_meta->detector_bbox_info.org_bbox_coords.height; + } + fprintf(_pose_file, + " \"bbox\": ["); + fprintf(_pose_file, "%f, %f, %f, %f", + left, + top, + width, + height); + fprintf(_pose_file, "]\n"); + } + //---Save bounding box coordinates--- - // Remember the position of "," so that we can remove it on the last entry. + // Remember the position of "," so that we can remove it on the last entry. fprintf(_pose_file, " }"); fgetpos(_pose_file, &g_fp_25_pos); fprintf(_pose_file, ", "); From f24f4e95ebe38a37a643ee070718b275c7647270 Mon Sep 17 00:00:00 2001 From: xunleiw <95458386+xunleiw@users.noreply.github.com> Date: Sat, 14 May 2022 18:05:35 -0700 Subject: [PATCH 2/2] Restore the bbox location due to padding and cropping org_bbox_coords are detected on the padded image frame. The output video frames have the padding removed by cropping. Thus the saved bbox coordinates in JSON format should recover the left and top WRT the original video frame by substracting _pad_dim. --- .../sources/deepstream_pose_estimation_app.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp b/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp index ad5cf49..6c08785 100644 --- a/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp +++ b/deepstream-bodypose-3d/sources/deepstream_pose_estimation_app.cpp @@ -986,7 +986,10 @@ void parse_25dpose_from_tensor_meta(NvDsInferTensorMeta *tensor_meta, width = obj_meta->detector_bbox_info.org_bbox_coords.width; height = obj_meta->detector_bbox_info.org_bbox_coords.height; } - fprintf(_pose_file, + // Restore the bbox location due to padding and cropping. + left -= _pad_dim; + top -= _pad_dim; + fprintf(_pose_file, " \"bbox\": ["); fprintf(_pose_file, "%f, %f, %f, %f", left,