static mv_engine_config_h gEngineConfigHandle = NULL;
static mv_source_h gSourceHandle = NULL;
const char *gInferenceExampleDir = NULL;
+static mv_point_s** gPldResultLandmarks = NULL;
+static float** gPldResultScore = NULL;
+static mv_pose_h gPoseHandle = NULL;
static bool gIsForeachSupportedCallBackInvoked = false;
static bool gIsImageClassifyCallBackInvoked = false;
static bool gIsObjectDetectCallBackInvoked = false;
static bool gIsFaceDetectCallBackInvoked = false;
static bool gIsFacialLandmarkDetectCallBackInvoked = false;
+static bool gIsPoseLandmarkDetectCallBackInvoked = false;
+static bool gIsGetPoseLandmark = false;
+static int gPldResultErr;
+static int gPldResultNumberOfPoses;
+static int gPldResultNumberOfLandmarks;
+static float gPoseCompareScore;
#define IC_MODEL_FILENAME "ic_tflite_model.tflite"
#define IC_LABEL_FILENAME "ic_label.txt"
#define FLD_MODEL_FILENAME "fld_tflite_model1.tflite"
+#define PLD_MODEL_FILENAME "pld_tflite_model.tflite"
+#define PLD_POSE_MAPPING_FILENAME "pld_pose_mapping.txt"
+#define PLD_MOCAP_FILEAME "pld_mocap.bvh"
+#define PLD_MOCAP_MAPPING_FILENAME "pld_mocap_mapping.txt"
+
static int set_image_classification_engine_config(mv_engine_config_h engineCfg)
{
int ret = MEDIA_VISION_ERROR_NONE;
return ret;
}
+static int set_pose_landmark_detection_engine_config(mv_engine_config_h engineCfg)
+{
+ int ret = MEDIA_VISION_ERROR_NONE;
+
+ char modelFilename[FILE_PATH_SIZE];
+ char poseMappingFilename[FILE_PATH_SIZE];
+ char *inputNodeName = "image";
+ char *outputNodeName[1] = { "Convolution_Pose_Machine/stage_5_out" };
+ snprintf(modelFilename, FILE_PATH_SIZE, "%s/models/%s",
+ gInferenceExampleDir, PLD_MODEL_FILENAME);
+ snprintf(poseMappingFilename, FILE_PATH_SIZE, "%s/models/%s",
+ gInferenceExampleDir, PLD_POSE_MAPPING_FILENAME);
+
+ ret = mv_engine_config_set_string_attribute(engineCfg,
+ MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+ modelFilename);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(engineCfg,
+ MV_INFERENCE_INPUT_DATA_TYPE,
+ MV_INFERENCE_DATA_FLOAT32);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_string_attribute(engineCfg,
+ MV_INFERENCE_MODEL_USER_FILE_PATH,
+ poseMappingFilename);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_double_attribute(engineCfg,
+ MV_INFERENCE_MODEL_MEAN_VALUE,
+ 0.0);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_double_attribute(engineCfg,
+ MV_INFERENCE_MODEL_STD_VALUE,
+ 1.0);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(engineCfg,
+ MV_INFERENCE_BACKEND_TYPE,
+ MV_INFERENCE_BACKEND_TFLITE);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(engineCfg,
+ MV_INFERENCE_TARGET_DEVICE_TYPE,
+ MV_INFERENCE_TARGET_DEVICE_CPU);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(engineCfg,
+ MV_INFERENCE_INPUT_TENSOR_WIDTH,
+ 192);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(engineCfg,
+ MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+ 192);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(engineCfg,
+ MV_INFERENCE_INPUT_TENSOR_CHANNELS,
+ 3);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_string_attribute(engineCfg,
+ MV_INFERENCE_INPUT_NODE_NAME,
+ inputNodeName);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_array_string_attribute(engineCfg,
+ MV_INFERENCE_OUTPUT_NODE_NAMES,
+ outputNodeName,
+ 1);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ return ret;
+}
+
static int load_image_to_media_source(
const char *file_path,
mv_source_h source)
gInferenceExampleDir = NULL;
}
+ if (gPldResultLandmarks){
+ for (int pose = 0; pose < gPldResultNumberOfPoses; ++pose)
+ free(gPldResultLandmarks[pose]);
+ free(gPldResultLandmarks);
+ gPldResultLandmarks = NULL;
+ }
+
+ if (gPldResultScore){
+ for (int pose = 0; pose < gPldResultNumberOfPoses; ++pose)
+ free(gPldResultScore[pose]);
+ free(gPldResultScore);
+ gPldResultScore = NULL;
+ }
+
+ if (gPoseHandle) {
+ mv_pose_destroy(gPoseHandle);
+ gPoseHandle = NULL;
+ }
+
printf("capi-media-vision mv_image tests CLEANUP is completed\n");
}
printf("Before return mv_inference_facial_landmark_detect_n2\n");
return 0;
}
+
+static void _pld_detected_cb(mv_source_h source,
+ mv_inference_pose_result_h locations,
+ int label,
+ void *user_data)
+{
+ gIsPoseLandmarkDetectCallBackInvoked = true;
+}
+
+/**
+ * @brief Positive test case of mv_inference_pose_landmark_detect()
+ * @testcase utc_mediavision_mv_inference_pose_landmark_detect_p
+ * @since_tizen 6.0
+ * @description Detect pose landmark on a human body
+ */
+int utc_mediavision_mv_inference_pose_landmark_detect_p(void)
+{
+ printf("Inside mv_inference_pose_landmark_detect_p\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ char imageFilename[FILE_PATH_SIZE];
+ assert_eq(set_pose_landmark_detection_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ int ret = mv_inference_configure(gInferenceHandle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_inference_prepare(gInferenceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ snprintf(imageFilename, FILE_PATH_SIZE, "%s/images/%s", gInferenceExampleDir, "poseLandmark.jpg");
+ ret = load_image_to_media_source(imageFilename, gSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ gInferenceHandle,
+ NULL,
+ _pld_detected_cb,
+ NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+ assert_eq(true, gIsPoseLandmarkDetectCallBackInvoked);
+
+ printf("Before return mv_inference_pose_landmark_detect_p\n");
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_inference_pose_landmark_detect()
+ * @testcase utc_mediavision_mv_inference_pose_landmark_detect_n1
+ * @since_tizen 6.0
+ * @description Detect pose landmark on a human body,
+ * but fail because an input parameter is NULL
+ */
+int utc_mediavision_mv_inference_pose_landmark_detect_n1(void)
+{
+ printf("Inside mv_inference_pose_landmark_detect_n1\n");
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ char imageFilename[FILE_PATH_SIZE];
+ assert_eq(set_pose_landmark_detection_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ int ret = mv_inference_configure(gInferenceHandle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_inference_prepare(gInferenceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ snprintf(imageFilename, FILE_PATH_SIZE, "%s/images/%s", gInferenceExampleDir, "poseLandmark.jpg");
+ ret = load_image_to_media_source(imageFilename, gSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ // source is NULL
+ ret = mv_inference_pose_landmark_detect(NULL,
+ gInferenceHandle,
+ NULL,
+ _pld_detected_cb,
+ NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ // inference handle is NULL
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ NULL,
+ NULL,
+ _pld_detected_cb,
+ NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ // callback is NULL
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ gInferenceHandle,
+ NULL,
+ NULL,
+ NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_inference_pose_landmark_detect_n1\n");
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_inference_pose_landmark_detect()
+ * @testcase utc_mediavision_mv_inference_pose_landmark_detect_n2
+ * @since_tizen 6.0
+ * @description Detect pose landmark on a human body,
+ * but fail because mv_inference_prepare() isn't called
+ */
+int utc_mediavision_mv_inference_pose_landmark_detect_n2(void)
+{
+ printf("Inside mv_inference_pose_landmark_detect_n2\n");
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ char imageFilename[FILE_PATH_SIZE];
+ assert_eq(set_pose_landmark_detection_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ int ret = mv_inference_configure(gInferenceHandle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ snprintf(imageFilename, FILE_PATH_SIZE, "%s/images/%s", gInferenceExampleDir, "poseLandmark.jpg");
+ ret = load_image_to_media_source(imageFilename, gSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ gInferenceHandle,
+ NULL,
+ _pld_detected_cb,
+ NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret);
+
+ printf("Before return mv_inference_pose_landmark_detect_n2\n");
+ return 0;
+}
+
+static void get_pose_landmark_detection_result_cb1(mv_source_h source,
+ mv_inference_pose_result_h result,
+ int label,
+ void *user_data)
+{
+ printf("Inside get_pose_landmark_detection_result_cb1\n");
+ gIsPoseLandmarkDetectCallBackInvoked = true;
+
+ gPldResultErr = mv_inference_pose_get_number_of_poses(result, &gPldResultNumberOfPoses);
+ printf("Before retrun get_pose_landmark_detection_result_cb1\n");
+}
+
+/**
+ * @function utc_mediavision_mv_inference_pose_landmark_detect_cb1_startup
+ * @description Inference module UTC startup code for mv_inference_pose_get_number_of_poses()
+ * @parameter NA
+ * @return NA
+ */
+void utc_capi_media_vision_inference_pose_landmark_detect_cb1_startup(void)
+{
+ printf("Inside utc_mediavision_mv_inference_pose_landmark_detect_cb1_startup\n");
+ utc_capi_media_vision_inference_startup2();
+
+ if (gStartupError != MEDIA_VISION_ERROR_NONE)
+ return;
+
+ char imageFilename[FILE_PATH_SIZE];
+ int ret = set_pose_landmark_detection_engine_config(gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("set_pose_landmark_detection_engine_config is failed\n");
+ return;
+ }
+
+ ret = mv_inference_configure(gInferenceHandle, gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_configure is failed\n");
+ return;
+ }
+
+ ret = mv_inference_prepare(gInferenceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_prepare is failed\n");
+ return;
+ }
+
+ snprintf(imageFilename, FILE_PATH_SIZE, "%s/images/%s", gInferenceExampleDir, "poseLandmark.jpg");
+ ret = load_image_to_media_source(imageFilename, gSourceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("load_image_to_media_source is failed\n");
+ return;
+ }
+
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ gInferenceHandle,
+ NULL,
+ get_pose_landmark_detection_result_cb1,
+ NULL);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_pose_landmark_detect is failed\n");
+ return;
+ }
+
+ printf("Before return utc_mediavision_mv_inference_pose_landmark_detect_cb1_startup\n");
+}
+
+/**
+ * @brief Positive test case of mv_inference_get_number_of_poses()
+ * @testcase utc_mediavision_mv_inference_get_number_of_poses_p
+ * @since_tizen 6.0
+ * @description Get the number of poses from a detected result
+ */
+int utc_mediavision_mv_inference_get_number_of_poses_p(void)
+{
+ printf("Inside mv_inference_get_number_of_poses_p\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ assert_eq(true, gIsPoseLandmarkDetectCallBackInvoked);
+ assert_eq(MEDIA_VISION_ERROR_NONE, gPldResultErr);
+ assert_gt(gPldResultNumberOfPoses, 0);
+
+ printf("Before return mv_inference_get_number_of_poses_p\n");
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_inference_get_number_of_poses()
+ * @testcase utc_mediavision_mv_inference_get_number_of_poses_n
+ * @since_tizen 6.0
+ * @description Get the number of poses from a detected result,
+ * but fail because handle is NULL
+ */
+int utc_mediavision_mv_inference_get_number_of_poses_n(void)
+{
+ printf("Inside mv_inference_get_number_of_poses_n\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ // handle is NULL
+ int ret = mv_inference_pose_get_number_of_poses(NULL, &gPldResultNumberOfPoses);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_inference_get_number_of_poses_n\n");
+ return 0;
+}
+
+static void get_pose_landmark_detection_result_cb2(mv_source_h source,
+ mv_inference_pose_result_h result,
+ int label,
+ void *user_data)
+{
+ printf("Inside get_pose_landmark_detection_result_cb2\n");
+ gIsPoseLandmarkDetectCallBackInvoked = true;
+
+ gPldResultErr = mv_inference_pose_get_number_of_landmarks(result, &gPldResultNumberOfLandmarks);
+ printf("Before retrun get_pose_landmark_detection_result_cb2\n");
+}
+
+/**
+ * @function utc_mediavision_mv_inference_pose_landmark_detect_cb2_startup
+ * @description Inference module UTC startup code for mv_inference_pose_get_number_of_landmarks()
+ * @parameter NA
+ * @return NA
+ */
+void utc_capi_media_vision_inference_pose_landmark_detect_cb2_startup(void)
+{
+ printf("Inside utc_mediavision_mv_inference_pose_landmark_detect_cb2_startup\n");
+ utc_capi_media_vision_inference_startup2();
+
+ if (gStartupError != MEDIA_VISION_ERROR_NONE)
+ return;
+
+ char imageFilename[FILE_PATH_SIZE];
+ int ret = set_pose_landmark_detection_engine_config(gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("set_pose_landmark_detection_engine_config is failed\n");
+ return;
+ }
+
+ ret = mv_inference_configure(gInferenceHandle, gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_configure is failed\n");
+ return;
+ }
+
+ ret = mv_inference_prepare(gInferenceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_prepare is failed\n");
+ return;
+ }
+
+ snprintf(imageFilename, FILE_PATH_SIZE, "%s/images/%s", gInferenceExampleDir, "poseLandmark.jpg");
+ ret = load_image_to_media_source(imageFilename, gSourceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("load_image_to_media_source is failed\n");
+ return;
+ }
+
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ gInferenceHandle,
+ NULL,
+ get_pose_landmark_detection_result_cb2,
+ NULL);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_pose_landmark_detect is failed\n");
+ return;
+ }
+
+ printf("Before return utc_mediavision_mv_inference_pose_landmark_detect_cb2_startup\n");
+}
+
+/**
+ * @brief Positive test case of mv_inference_get_number_of_landmarks()
+ * @testcase utc_mediavision_mv_inference_get_number_of_landmarks_p
+ * @since_tizen 6.0
+ * @description Get the number of landmarks from a detected result
+ */
+int utc_mediavision_mv_inference_get_number_of_landmarks_p(void)
+{
+ printf("Inside mv_inference_get_number_of_landmarks_p\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ assert_eq(true, gIsPoseLandmarkDetectCallBackInvoked);
+ assert_eq(MEDIA_VISION_ERROR_NONE, gPldResultErr);
+ assert_gt(gPldResultNumberOfLandmarks, 0);
+
+ printf("Before return mv_inference_get_number_of_landmarks_p\n");
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_inference_get_number_of_landmarks()
+ * @testcase utc_mediavision_mv_inference_get_number_of_landmarks_n
+ * @since_tizen 6.0
+ * @description Get the number of landmarks from a detected result,
+ * but fail because handle is NULL
+ */
+int utc_mediavision_mv_inference_get_number_of_landmarks_n(void)
+{
+ printf("Inside mv_inference_get_number_of_landmarks_n\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ // handle is NULL
+ int ret = mv_inference_pose_get_number_of_landmarks(NULL, &gPldResultNumberOfLandmarks);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_inference_get_number_of_landmarks_n\n");
+ return 0;
+}
+
+static void get_pose_landmark_detection_result_cb3(mv_source_h source,
+ mv_inference_pose_result_h result,
+ int label,
+ void *user_data)
+{
+ printf("Inside get_pose_landmark_detection_result_cb3\n");
+ gIsPoseLandmarkDetectCallBackInvoked = true;
+
+ // get the number of poses
+ gPldResultErr = mv_inference_pose_get_number_of_poses(result, &gPldResultNumberOfPoses);
+ if (gPldResultErr != MEDIA_VISION_ERROR_NONE)
+ return;
+
+ // get the number of landmarks
+ gPldResultErr = mv_inference_pose_get_number_of_landmarks(result, &gPldResultNumberOfLandmarks);
+ if (gPldResultErr != MEDIA_VISION_ERROR_NONE)
+ return;
+
+ // allocate memory with the number of poses
+ gPldResultLandmarks = (mv_point_s **)malloc(gPldResultNumberOfPoses * sizeof(mv_point_s *));
+ gPldResultScore = (float **)malloc(gPldResultNumberOfPoses * sizeof(float *));
+ for (int pose = 0; pose < gPldResultNumberOfPoses; ++pose) {
+ // allocate memory with the number of landmarks
+ gPldResultLandmarks[pose] = (mv_point_s *)malloc(gPldResultNumberOfLandmarks * sizeof(mv_point_s));
+ gPldResultScore[pose] = (float *)malloc(gPldResultNumberOfLandmarks * sizeof(float));
+ for (int part = 0; part < gPldResultNumberOfLandmarks; ++part) {
+ gPldResultErr = mv_inference_pose_get_landmark(result, pose, part,
+ &(gPldResultLandmarks[pose][part]),
+ &(gPldResultScore[pose][part]));
+ if (gPldResultErr != MEDIA_VISION_ERROR_NONE)
+ return;
+ }
+ }
+
+ gIsGetPoseLandmark = true;
+ printf("Before retrun get_pose_landmark_detection_result_cb3\n");
+}
+
+/**
+ * @function utc_mediavision_mv_inference_pose_landmark_detect_cb3_startup
+ * @description Inference module UTC startup code for mv_inference_pose_get_landmark()
+ * @parameter NA
+ * @return NA
+ */
+void utc_capi_media_vision_inference_pose_landmark_detect_cb3_startup(void)
+{
+ printf("Inside utc_mediavision_mv_inference_pose_landmark_detect_cb3_startup\n");
+ utc_capi_media_vision_inference_startup2();
+
+ if (gStartupError != MEDIA_VISION_ERROR_NONE)
+ return;
+
+ char imageFilename[FILE_PATH_SIZE];
+ int ret = set_pose_landmark_detection_engine_config(gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("set_pose_landmark_detection_engine_config is failed\n");
+ return;
+ }
+
+ ret = mv_inference_configure(gInferenceHandle, gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_configure is failed\n");
+ return;
+ }
+
+ ret = mv_inference_prepare(gInferenceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_prepare is failed\n");
+ return;
+ }
+
+ snprintf(imageFilename, FILE_PATH_SIZE, "%s/images/%s", gInferenceExampleDir, "poseLandmark.jpg");
+ ret = load_image_to_media_source(imageFilename, gSourceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("load_image_to_media_source is failed\n");
+ return;
+ }
+
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ gInferenceHandle,
+ NULL,
+ get_pose_landmark_detection_result_cb3,
+ NULL);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_pose_landmark_detect is failed\n");
+ return;
+ }
+
+ printf("Before return utc_mediavision_mv_inference_pose_landmark_detect_cb3_startup\n");
+}
+
+/**
+ * @brief Positive test case of mv_inference_get_landmark()
+ * @testcase utc_mediavision_mv_inference_get_landmark_p
+ * @since_tizen 6.0
+ * @description Get landmarks from a detected result
+ */
+int utc_mediavision_mv_inference_get_landmark_p(void)
+{
+ printf("Inside mv_inference_get_landmark_p\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ assert_eq(true, gIsPoseLandmarkDetectCallBackInvoked);
+ assert_eq(MEDIA_VISION_ERROR_NONE, gPldResultErr);
+ assert_gt(gPldResultNumberOfPoses, 0);
+ assert_gt(gPldResultNumberOfLandmarks, 0);
+ assert_eq(true, gIsGetPoseLandmark);
+
+ printf("Before return mv_inference_get_landmark_p\n");
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_inference_get_landmark()
+ * @testcase utc_mediavision_mv_inference_get_landmark_n
+ * @since_tizen 6.0
+ * @description Get landmarks from a detected result,
+ * but fail because handle is NULL
+ */
+int utc_mediavision_mv_inference_get_landmark_n(void)
+{
+ printf("Inside mv_inference_get_landmark_n\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ // handle is NULL
+ mv_point_s landmark;
+ float score;
+ int ret = mv_inference_pose_get_landmark(NULL, 0, 0, &landmark, &score);
+
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_inference_get_landmark_n\n");
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_pose_create_p()
+ * @testcase utc_mediavision_mv_pose_create_p
+ * @since_tizen 6.0
+ * @description Create pose handle
+ */
+int utc_mediavision_mv_pose_create_p(void)
+{
+ printf("Inside mv_pose_create_p\n");
+
+ mv_pose_h poseHandle = NULL;
+ int ret = mv_pose_create(&poseHandle);
+ if (!isVisionSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_pose_destroy(poseHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("Before return mv_pose_create_p\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_pose_create()
+ * @testcase utc_mediavision_mv_pose_create_n
+ * @since_tizen 6.0
+ * @description Create pose handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_pose_create_n(void)
+{
+ printf("Inside mv_pose_create_n\n");
+
+ int ret = mv_pose_create(NULL);
+ if (!isVisionSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_pose_create_n\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_pose_destroy_p()
+ * @testcase utc_mediavision_mv_pose_destroy_p
+ * @since_tizen 6.0
+ * @description Destroy pose handle
+ */
+int utc_mediavision_mv_pose_destroy_p(void)
+{
+ printf("Inside mv_pose_destroy_p\n");
+
+ mv_pose_h poseHandle = NULL;
+ int ret = mv_pose_create(&poseHandle);
+ if (!isVisionSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_pose_destroy(poseHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("Before return mv_pose_destroy_p\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_pose_destroy_n()
+ * @testcase utc_mediavision_mv_pose_destroy_n
+ * @since_tizen 6.0
+ * @description Destroy pose handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_pose_destroy_n(void)
+{
+ printf("Inside mv_pose_destroy_n\n");
+
+ int ret = mv_pose_destroy(NULL);
+ if (!isVisionSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_pose_destroy_n\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_pose_set_from_file()
+ * @testcase utc_mediavision_mv_pose_set_from_file_p
+ * @since_tizen 6.0
+ * @description Set pose mocap file and its mapping file
+ */
+int utc_mediavision_mv_pose_set_from_file_p(void)
+{
+ printf("Inside mv_pose_set_from_file_p\n");
+
+ mv_pose_h poseHandle = NULL;
+ int ret = mv_pose_create(&poseHandle);
+ if (!isVisionSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char poseMocapFilename[FILE_PATH_SIZE];
+ char poseMocapMappingFilename[FILE_PATH_SIZE];
+ snprintf(poseMocapFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap.bvh");
+ snprintf(poseMocapMappingFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap_mapping.txt");
+
+ ret = mv_pose_set_from_file(poseHandle, poseMocapFilename, poseMocapMappingFilename);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_pose_destroy(poseHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("Before return mv_pose_set_from_file_p\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_pose_set_from_file()
+ * @testcase utc_mediavision_mv_pose_set_from_file_n1
+ * @since_tizen 6.0
+ * @description Set pose mocap file and its mapping file,
+ * but fail because file paths are NULL
+ */
+int utc_mediavision_mv_pose_set_from_file_n1(void)
+{
+ printf("Inside mv_pose_set_from_file_n1\n");
+
+ mv_pose_h poseHandle = NULL;
+ int ret = mv_pose_create(&poseHandle);
+ if (!isVisionSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char poseMocapFilename[FILE_PATH_SIZE];
+ char poseMocapMappingFilename[FILE_PATH_SIZE];
+ snprintf(poseMocapFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap.bvh");
+ snprintf(poseMocapMappingFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap_mapping.txt");
+
+ // hand is NULL
+ ret = mv_pose_set_from_file(NULL, poseMocapFilename, poseMocapMappingFilename);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ // motion capture file path is NULL
+ ret = mv_pose_set_from_file(poseHandle, NULL, poseMocapMappingFilename);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ // motion mapping file path is NULL
+ ret = mv_pose_set_from_file(poseHandle, poseMocapFilename, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_pose_destroy(poseHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("Before return mv_pose_set_from_file_n1\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_pose_set_from_file()
+ * @testcase utc_mediavision_mv_pose_set_from_file_n2
+ * @since_tizen 6.0
+ * @description Set pose mocap file and its mapping file,
+ * but fail because file paths are fake (invalid)
+ */
+int utc_mediavision_mv_pose_set_from_file_n2(void)
+{
+ printf("Inside mv_pose_set_from_file_n2\n");
+
+ mv_pose_h poseHandle = NULL;
+ int ret = mv_pose_create(&poseHandle);
+ if (!isVisionSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char poseMocapFilename[FILE_PATH_SIZE];
+ char poseMocapMappingFilename[FILE_PATH_SIZE];
+ snprintf(poseMocapFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap.bvh");
+ snprintf(poseMocapMappingFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap_mapping.txt");
+
+ // fakefile doesn't exist
+ char fakeFilename[FILE_PATH_SIZE];
+ snprintf(fakeFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "fakefile");
+
+ // motion capture file path is invalid
+ ret = mv_pose_set_from_file(poseHandle, fakeFilename, poseMocapMappingFilename);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PATH, ret);
+
+ // motion mapping file path is invalid
+ ret = mv_pose_set_from_file(poseHandle, poseMocapFilename, fakeFilename);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PATH, ret);
+
+ ret = mv_pose_destroy(poseHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("Before return mv_pose_set_from_file_n2\n");
+
+ return 0;
+}
+
+static void get_pose_landmark_detection_result_cb4(mv_source_h source,
+ mv_inference_pose_result_h result,
+ int label,
+ void *user_data)
+{
+ printf("Inside get_pose_landmark_detection_result_cb4\n");
+ gIsPoseLandmarkDetectCallBackInvoked = true;
+
+ mv_pose_h *pose = (mv_pose_h *)user_data;
+ int part = MV_INFERENCE_HUMAN_BODY_PART_LEG_RIGHT | MV_INFERENCE_HUMAN_BODY_PART_LEG_LEFT;
+ gPldResultErr = mv_pose_compare(*pose, result, part, &gPoseCompareScore);
+ if (gPldResultErr != MEDIA_VISION_ERROR_NONE)
+ return;
+
+ printf("Before retrun get_pose_landmark_detection_result_cb4\n");
+}
+
+/**
+ * @function utc_mediavision_mv_inference_pose_landmark_detect_cb4_startup
+ * @description Inference module UTC startup code for mv_pose_compare()
+ * @parameter NA
+ * @return NA
+ */
+void utc_capi_media_vision_inference_pose_landmark_detect_cb4_startup(void)
+{
+ printf("Inside utc_mediavision_mv_inference_pose_landmark_detect_cb4_startup\n");
+ utc_capi_media_vision_inference_startup2();
+
+ if (gStartupError != MEDIA_VISION_ERROR_NONE)
+ return;
+
+ char imageFilename[FILE_PATH_SIZE];
+ int ret = set_pose_landmark_detection_engine_config(gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("set_pose_landmark_detection_engine_config is failed\n");
+ return;
+ }
+
+ ret = mv_inference_configure(gInferenceHandle, gEngineConfigHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_configure is failed\n");
+ return;
+ }
+
+ ret = mv_inference_prepare(gInferenceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_prepare is failed\n");
+ return;
+ }
+
+ snprintf(imageFilename, FILE_PATH_SIZE, "%s/images/%s", gInferenceExampleDir, "poseLandmark.jpg");
+ ret = load_image_to_media_source(imageFilename, gSourceHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("load_image_to_media_source is failed\n");
+ return;
+ }
+
+ ret = mv_pose_create(&gPoseHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_pose_create is failed\n");
+ return;
+ }
+
+ char poseMocapFilename[FILE_PATH_SIZE];
+ char poseMocapMappingFilename[FILE_PATH_SIZE];
+ snprintf(poseMocapFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap.bvh");
+ snprintf(poseMocapMappingFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap_mapping.txt");
+
+ ret = mv_pose_set_from_file(gPoseHandle, poseMocapFilename, poseMocapMappingFilename);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_pose_set_from_file is failed\n");
+ return;
+ }
+
+ ret = mv_inference_pose_landmark_detect(gSourceHandle,
+ gInferenceHandle,
+ NULL,
+ get_pose_landmark_detection_result_cb4,
+ &gPoseHandle);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ printf("mv_inference_pose_landmark_detect is failed\n");
+ return;
+ }
+
+ printf("Before return utc_mediavision_mv_inference_pose_landmark_detect_cb4_startup\n");
+}
+
+/**
+ * @brief Positive test case of mv_pose_compare()
+ * @testcase utc_mediavision_mv_pose_compare_p
+ * @since_tizen 6.0
+ * @description Compare a result which is detected by mv_inference_pose_landmark_detect()
+ * with a pose which is set by mv_pose_set_from_file()
+ */
+int utc_mediavision_mv_pose_compare_p(void)
+{
+ printf("Inside mv_inference_get_landmark_p\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ assert_eq(true, gIsPoseLandmarkDetectCallBackInvoked);
+ assert_eq(MEDIA_VISION_ERROR_NONE, gPldResultErr);
+ assert_gt(gPoseCompareScore, 0.5);
+
+ printf("Before return mv_inference_get_landmark_p\n");
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_pose_compare()
+ * @testcase utc_mediavision_mv_pose_compare_n
+ * @since_tizen 6.0
+ * @description Compare a result which is detected by mv_inference_pose_landmark_detect()
+ * with a pose which is set by mv_pose_set_from_file(),
+ * but fail because hanlde is NULL
+ */
+int utc_mediavision_mv_pose_compare_n(void)
+{
+ printf("Inside mv_pose_compare_n\n");
+
+ mv_pose_h poseHandle = NULL;
+ int ret = mv_pose_create(&poseHandle);
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char poseMocapFilename[FILE_PATH_SIZE];
+ char poseMocapMappingFilename[FILE_PATH_SIZE];
+ snprintf(poseMocapFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap.bvh");
+ snprintf(poseMocapMappingFilename, FILE_PATH_SIZE, "%s/models/%s", gInferenceExampleDir, "pld_mocap_mapping.txt");
+
+ ret = mv_pose_set_from_file(poseHandle, poseMocapFilename, poseMocapMappingFilename);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ int part = MV_INFERENCE_HUMAN_BODY_PART_LEG_RIGHT | MV_INFERENCE_HUMAN_BODY_PART_LEG_LEFT;
+ // handle is NULL
+ ret = mv_pose_compare(poseHandle, NULL, part, &gPoseCompareScore);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_pose_compare_n\n");
+ return 0;
+}