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>
* 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
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;
/**
}
if (mPoseResult) {
+ for (int poseIndex = 0; poseIndex < mPoseResult->number_of_poses; ++poseIndex) {
+ delete [] mPoseResult->landmarks[poseIndex];
+ }
delete [] mPoseResult->landmarks;
delete mPoseResult;
}
}
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;
+ }
}
}
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);
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);
}
}
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);
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);
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)));
}