Fix landmarks to two dimensions 60/245160/2 accepted/tizen_6.0_unified_hotfix tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.121630 accepted/tizen/6.0/unified/hotfix/20201103.003858 accepted/tizen/6.0/unified/hotfix/20201103.050748 accepted/tizen/unified/20201007.092257 submit/tizen/20201007.030722 submit/tizen_6.0/20201029.205102 submit/tizen_6.0_hotfix/20201102.192502 submit/tizen_6.0_hotfix/20201103.114802 tizen_6.0.m2_release
authorTae-Young Chung <ty83.chung@samsung.com>
Mon, 5 Oct 2020 03:52:12 +0000 (12:52 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Wed, 7 Oct 2020 01:16:03 +0000 (10:16 +0900)
mv_inference_pose_s composes of number_of_pose and mv_inference_landmark_s.
The mv_inference_landmarks_s should include the pose index as well as landmark index.
So, fix the landmarks from one dimensions to two dimensions.

Change-Id: I68ce167846618487521df5ec92652e944413edf0
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
include/mv_inference.h
include/mv_inference_private.h
mv_inference/inference/src/Inference.cpp
mv_inference/inference/src/mv_inference_open.cpp

index 3ed5c5a..6949592 100644 (file)
@@ -910,6 +910,7 @@ int mv_pose_set_from_file(mv_pose_h pose, const char *motion_capture_file_path,
  *          Their similarity will be given by the score between 0 ~ 1.
  *
  * @since_tizen 6.0
+ * @remarks If @a action contains multiple poses, the first pose is used for comparison.
  *
  * @param[in] pose   The handle to the pose
  * @param[in] action The action pose
index 8125283..95dff31 100644 (file)
@@ -50,7 +50,7 @@ typedef struct {
 typedef struct {
     int number_of_poses;
     int number_of_landmarks_per_pose;            /**< The number of landmarks*/
-    mv_inference_landmark_s *landmarks; /**< A set of landmarks describing pose */
+    mv_inference_landmark_s **landmarks; /**< A set of landmarks describing pose */
 } mv_inference_pose_s;
 
 /**
index 771da37..2847190 100644 (file)
@@ -138,6 +138,9 @@ namespace inference
                }
 
                if (mPoseResult) {
+                       for (int poseIndex = 0; poseIndex < mPoseResult->number_of_poses; ++poseIndex) {
+                               delete [] mPoseResult->landmarks[poseIndex];
+                       }
                        delete [] mPoseResult->landmarks;
                        delete mPoseResult;
                }
@@ -1456,14 +1459,17 @@ namespace inference
                        }
 
                        mPoseResult->number_of_poses= number_of_poses;
-                       mPoseResult->landmarks = new mv_inference_landmark_s[number_of_landmarks];
                        mPoseResult->number_of_landmarks_per_pose = number_of_landmarks;
-                       for (int index = 0; index < number_of_landmarks; ++index) {
-                               mPoseResult->landmarks[index].isAvailable = false;
-                               mPoseResult->landmarks[index].point.x = -1;
-                               mPoseResult->landmarks[index].point.y = -1;
-                               mPoseResult->landmarks[index].label = -1;
-                               mPoseResult->landmarks[index].score = -1.0f;
+                       mPoseResult->landmarks = new mv_inference_landmark_s*[number_of_poses];
+                       for (int poseIndex = 0; poseIndex < number_of_poses; ++poseIndex) {
+                               mPoseResult->landmarks[poseIndex] = new mv_inference_landmark_s[number_of_landmarks];
+                               for (int landmarkIndex = 0; landmarkIndex < number_of_landmarks; ++landmarkIndex) {
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].isAvailable = false;
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].point.x = -1;
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].point.y = -1;
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].label = -1;
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].score = -1.0f;
+                               }
                        }
                }
 
@@ -1488,15 +1494,13 @@ namespace inference
                                        LOGI("landmarkIndex[%2d] - mapping to [%2d]: x[%.3f], y[%.3f], score[%.3f]",
                                                        landmarkIndex, part, loc2f.x, loc2f.y, score);
 
-                                       mPoseResult->landmarks[landmarkIndex].isAvailable = true;
-                                       mPoseResult->landmarks[landmarkIndex].point.x = static_cast<int>(static_cast<float>(width) * loc2f.x);
-                                       mPoseResult->landmarks[landmarkIndex].point.y = static_cast<int>(static_cast<float>(height) * loc2f.y);
-                                       mPoseResult->landmarks[landmarkIndex].score = score;
-                                       mPoseResult->landmarks[landmarkIndex].label = -1;
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].isAvailable = true;
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].point.x = static_cast<int>(static_cast<float>(width) * loc2f.x);
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].point.y = static_cast<int>(static_cast<float>(height) * loc2f.y);
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].score = score;
+                                       mPoseResult->landmarks[poseIndex][landmarkIndex].label = -1;
                        }
                }
-               mPoseResult->number_of_landmarks_per_pose = number_of_landmarks;
-               mPoseResult->number_of_poses = number_of_poses;
 
                *detectionResults = static_cast<mv_inference_pose_result_h>(mPoseResult);
 
index 9a64555..c2c7f2b 100644 (file)
@@ -833,9 +833,9 @@ int mv_inference_pose_landmark_detect_open(
        for (int pose = 0; pose < tmp->number_of_poses; ++pose) {
                for (int index = 0; index < tmp->number_of_landmarks_per_pose; ++index) {
                        LOGI("PoseIdx[%2d]: x[%d], y[%d], score[%.3f]", index,
-                                                                               tmp->landmarks[index].point.x,
-                                                                               tmp->landmarks[index].point.y,
-                                                                               tmp->landmarks[index].score);
+                                                                               tmp->landmarks[pose][index].point.x,
+                                                                               tmp->landmarks[pose][index].point.y,
+                                                                               tmp->landmarks[pose][index].score);
                }
        }
 
@@ -885,9 +885,9 @@ int mv_inference_pose_get_landmark_open(
        if (part_index < 0 || part_index >= handle->number_of_landmarks_per_pose)
                return MEDIA_VISION_ERROR_INVALID_PARAMETER;
 
-       *location = handle->landmarks[part_index].point;
+       *location = handle->landmarks[pose_index][part_index].point;
 
-       *score = handle->landmarks[part_index].score;
+       *score = handle->landmarks[pose_index][part_index].score;
 
        LOGI("[%d]:(%dx%d) - %.4f", pose_index, location->x, location->y, *score);
 
@@ -904,7 +904,7 @@ int mv_inference_pose_get_label_open(
        if (pose_index < 0 || pose_index >= handle->number_of_poses)
                return MEDIA_VISION_ERROR_INVALID_PARAMETER;
 
-       *label = handle->landmarks[0].label;
+       *label = handle->landmarks[pose_index][0].label;
 
        LOGI("[%d]: label(%d)", pose_index, *label);
 
@@ -981,13 +981,13 @@ int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int
        mv_inference_pose_s *pAction = static_cast<mv_inference_pose_s *>(action);
 
        for (int k = 0; k < HUMAN_POSE_MAX_LANDMARKS; ++k) {
-               if (pAction->landmarks[k].point.x == -1 || pAction->landmarks[k].point.y == -1) {
+               if (pAction->landmarks[0][k].point.x == -1 || pAction->landmarks[0][k].point.y == -1) {
                        actionParts.push_back(std::make_pair(false, cv::Point(-1,-1)));
                        continue;
                }
 
-               actionParts.push_back(std::make_pair(true, cv::Point(pAction->landmarks[k].point.x,
-                                                                                                                       pAction->landmarks[k].point.y)));
+               actionParts.push_back(std::make_pair(true, cv::Point(pAction->landmarks[0][k].point.x,
+                                                                                                                       pAction->landmarks[0][k].point.y)));
 
        }