mv_inference: Revert Pose Estimation API support 91/237191/2 accepted/tizen/unified/20200628.221638 submit/tizen/20200626.050805 submit/tizen/20200626.060446 submit/tizen/20200626.070253
authorInki Dae <inki.dae@samsung.com>
Fri, 26 Jun 2020 01:25:49 +0000 (10:25 +0900)
committerInki Dae <inki.dae@samsung.com>
Fri, 26 Jun 2020 01:28:26 +0000 (10:28 +0900)
Pose Estimation API may be changed so this patch
reverts this API support. Pose Estimation API support
will be posted later.

Change-Id: I1aa2bf4bd3cb46a1cf70943e53be47326c79a8e0
Signed-off-by: Inki Dae <inki.dae@samsung.com>
include/mv_inference.h
mv_inference/inference/include/Inference.h
mv_inference/inference/include/mv_inference_open.h
mv_inference/inference/src/Inference.cpp
mv_inference/inference/src/mv_inference.c
mv_inference/inference/src/mv_inference_open.cpp
test/testsuites/inference/inference_test_suite.c

index a30a7c8..a07f2eb 100644 (file)
@@ -635,12 +635,6 @@ typedef void (*mv_inference_facial_landmark_detected_cb)(
        const mv_point_s *locations,
        void *user_data);
 
-typedef void (*mv_inference_pose_estimation_detected_cb)(
-       mv_source_h source,
-       int number_of_landmarks,
-       const mv_point_s *locations,
-       void *user_data);
-
 /**
  * @brief Performs facial landmarks detection on the @a source.
  * @details Use this function to launch facial landmark detection.
@@ -684,48 +678,6 @@ int mv_inference_facial_landmark_detect(
        void *user_data);
 
 /**
- * @brief Performs pose estimation detection on the @a source.
- * @details Use this function to launch pose estimation detection.
- *          Each time when mv_inference_pose_estimation_detect() is
- *          called, @a detected_cb will receive a list pose estimation's locations
- *          in the media source.
- *
- * @since_tizen 6.0
- * @remarks This function is synchronous and may take considerable time to run.
- *
- * @param[in] source         The handle to the source of the media
- * @param[in] infer          The handle to the inference
- * @param[in] roi            Rectangular area including a face in @a source which
- *                           will be analyzed. If NULL, then the whole source will be
- *                           analyzed.
- * @param[in] detected_cb    The callback which will receive the detection results.
- * @param[in] user_data      The user data passed from the code where
- *                           mv_inference_pose_estimation_detect() is invoked.
- *                           This data will be accessible in @a detected_cb callback.
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INTERNAL          Internal error
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
- *                                                  isn't supported
- *
- * @pre Create a source handle by calling mv_create_source()
- * @pre Create an inference handle by calling mv_inference_create()
- * @pre Configure an inference handle by calling mv_inference_configure()
- * @pre Prepare an inference by calling mv_inference_prepare()
- * @post @a detected_cb will be called to provide detection results
- *
- * @see mv_inference_pose_estimation_detected_cb()
- */
-int mv_inference_pose_estimation_detect(
-       mv_source_h source,
-       mv_inference_h infer,
-       mv_rectangle_s *roi,
-       mv_inference_pose_estimation_detected_cb detected_cb,
-       void *user_data);
-
-/**
  * @}
  */
 
index 895f6d5..4c8204b 100644 (file)
@@ -60,11 +60,6 @@ typedef struct _FacialLandMarkDetectionResults {
        std::vector<cv::Point> locations;
 } FacialLandMarkDetectionResults; /**< structure FacialLandMarkDetectionResults */
 
-typedef struct _PoseEstimationResults {
-       int number_of_pose_estimation;
-       std::vector<cv::Point> locations;
-} PoseEstimationResults; /**< structure PoseEstimationResults */
-
 namespace mediavision
 {
 namespace inference
@@ -294,14 +289,6 @@ namespace inference
                 */
                int GetFacialLandMarkDetectionResults(FacialLandMarkDetectionResults *results);
 
-               /**
-                * @brief       Gets the PoseEstimationDetectionResults
-                *
-                * @since_tizen 6.0
-                * @return @c true on success, otherwise a negative error value
-                */
-               int GetPoseEstimationDetectionResults(PoseEstimationResults *results);
-
                int GetResults(std::vector<std::vector<int> > *dimInfo,
                                           std::vector<float *> *results);
 
index 43ce8e4..3e3225f 100644 (file)
@@ -491,49 +491,6 @@ extern "C"
                        mv_inference_facial_landmark_detected_cb detected_cb,
                        void *user_data);
 
-       /**
-        * @brief Performs pose estimation detection on the @a source
-        * @details Use this function to launch pose estimation detection.
-        *          Each time when mv_inference_pose_estimation_detect() is
-        *          called, @a detected_cb will receive a list pose estimation's locations
-        *          on the media source.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] source         The handle to the source of the media
-        * @param [in] infer          The handle to the inference
-        * @param[in] roi            Rectangular box bounding face image on the
-        *                           @a source. If NULL, then full source will be
-        *                           analyzed.
-        * @param [in] detected_cb    The callback which will be called for
-        *                            detecting facial landmark on media source.
-        *                            This callback will receive the detection results.
-        * @param [in] user_data      The user data passed from the code where
-        *                            @ref mv_inference_facial_landmark_detect() is invoked.
-        *                            This data will be accessible from @a detected_cb callback.
-        *
-        * @return @c 0 on success, otherwise a negative error value
-        * @retval #MEDIA_VISION_ERROR_NONE Successful
-        * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
-        * @retval #MEDIA_VISION_ERROR_INTERNAL          Internal error
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
-        *                                                  isn't supported
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        *
-        * @pre Create a source handle by calling @ref mv_create_source()
-        * @pre Create an inference handle by calling @ref mv_inference_create()
-        * @pre Configure an inference handle by calling @ref mv_inference_configure()
-        * @pre Prepare an inference by calling @ref mv_inference_prepare()
-        * @post @a detected_cb will be called to process detection results
-        *
-        * @see mv_inference_pose_estimation_detected_cb
-        */
-       int mv_inference_pose_estimation_detect_open(
-                       mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-                       mv_inference_pose_estimation_detected_cb detected_cb,
-                       void *user_data);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 03714a3..d7e13f9 100644 (file)
@@ -1360,67 +1360,5 @@ namespace inference
                return MEDIA_VISION_ERROR_NONE;
        }
 
-       int Inference::GetPoseEstimationDetectionResults(
-                       PoseEstimationResults *detectionResults)
-       {
-               tensor_t outputData;
-
-               // Get inference result and contain it to outputData.
-               int ret = FillOutputResult(outputData);
-               if (ret != MEDIA_VISION_ERROR_NONE) {
-                       LOGE("Fail to get output result.");
-                       return ret;
-               }
-
-               std::vector<std::vector<int> > inferDimInfo(outputData.dimInfo);
-               std::vector<void *> inferResults(outputData.data.begin(),
-                                                                                outputData.data.end());
-
-               long number_of_pose = inferDimInfo[0][3];
-               float *tmp = static_cast<float *>(inferResults[0]);
-               cv::Size heatMapSize(inferDimInfo[0][1], inferDimInfo[0][2]);
-
-               cv::Point loc;
-               double score;
-               cv::Mat blurredHeatMap;
-
-               cv::Mat reShapeTest(cv::Size(inferDimInfo[0][2], inferDimInfo[0][1]),
-                                                       CV_32FC(inferDimInfo[0][3]), (void *) tmp);
-
-               cv::Mat multiChannels[inferDimInfo[0][3]];
-               split(reShapeTest, multiChannels);
-
-               float ratioX = static_cast<float>(mSourceSize.width) /
-                                          static_cast<float>(inferDimInfo[0][2]);
-               float ratioY = static_cast<float>(mSourceSize.height) /
-                                          static_cast<float>(inferDimInfo[0][1]);
-
-               PoseEstimationResults results;
-               results.number_of_pose_estimation = 0;
-               for (int poseIdx = 0; poseIdx < number_of_pose; poseIdx++) {
-                       cv::Mat heatMap = multiChannels[poseIdx];
-
-                       cv::GaussianBlur(heatMap, blurredHeatMap, cv::Size(), 5.0, 5.0);
-                       cv::minMaxLoc(heatMap, NULL, &score, NULL, &loc);
-
-                       LOGI("PoseIdx[%2d]: x[%2d], y[%2d], score[%.3f]", poseIdx, loc.x,
-                                loc.y, score);
-                       LOGI("PoseIdx[%2d]: x[%2d], y[%2d], score[%.3f]", poseIdx,
-                                static_cast<int>(static_cast<float>(loc.x + 1) * ratioX),
-                                static_cast<int>(static_cast<float>(loc.y + 1) * ratioY),
-                                score);
-
-                       loc.x = static_cast<int>(static_cast<float>(loc.x + 1) * ratioX);
-                       loc.y = static_cast<int>(static_cast<float>(loc.y + 1) * ratioY);
-                       results.locations.push_back(loc);
-                       results.number_of_pose_estimation++;
-               }
-
-               *detectionResults = results;
-               LOGE("Inference: PoseEstimationResults: %d\n",
-                        results.number_of_pose_estimation);
-               return MEDIA_VISION_ERROR_NONE;
-       }
-
 } /* Inference */
 } /* MediaVision */
index 50e0f13..4f2d02c 100644 (file)
@@ -315,33 +315,4 @@ int mv_inference_facial_landmark_detect(
        return ret;
 
 #endif
-}
-
-int mv_inference_pose_estimation_detect(
-               mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-               mv_inference_pose_estimation_detected_cb detected_cb, void *user_data)
-{
-       MEDIA_VISION_SUPPORT_CHECK(
-                       __mv_inference_face_check_system_info_feature_supported());
-       MEDIA_VISION_INSTANCE_CHECK(source);
-       MEDIA_VISION_INSTANCE_CHECK(infer);
-       MEDIA_VISION_NULL_ARG_CHECK(detected_cb);
-
-       MEDIA_VISION_FUNCTION_ENTER();
-
-       int ret = MEDIA_VISION_ERROR_NONE;
-
-#ifdef MEDIA_VISION_INFERENCE_LICENCE_PORT
-       /*
-       ret = mv_inference_pose_estimation_lic(source, infer, detected_cb, user_data);
-       */
-#else
-
-       ret = mv_inference_pose_estimation_detect_open(source, infer, roi,
-                                                                                                  detected_cb, user_data);
-
-       MEDIA_VISION_FUNCTION_LEAVE();
-
-       return ret;
-#endif
 }
\ No newline at end of file
index fc7d72a..09f9544 100644 (file)
@@ -784,47 +784,4 @@ int mv_inference_facial_landmark_detect_open(
        detected_cb(source, numberOfLandmarks, locations.data(), user_data);
 
        return ret;
-}
-
-int mv_inference_pose_estimation_detect_open(
-               mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-               mv_inference_pose_estimation_detected_cb detected_cb, void *user_data)
-{
-       Inference *pInfer = static_cast<Inference *>(infer);
-
-       int ret = MEDIA_VISION_ERROR_NONE;
-       int numberOfPoseEstimation = 0;
-       std::vector<mv_source_h> sources;
-       std::vector<mv_rectangle_s> rects;
-
-       sources.push_back(source);
-
-       if (roi != NULL)
-               rects.push_back(*roi);
-
-       ret = pInfer->Run(sources, rects);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to run inference");
-               return ret;
-       }
-
-       PoseEstimationResults poseEstimationResults;
-       ret = pInfer->GetPoseEstimationDetectionResults(&poseEstimationResults);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference results");
-               return ret;
-       }
-
-       numberOfPoseEstimation = poseEstimationResults.number_of_pose_estimation;
-
-       std::vector<mv_point_s> locations(numberOfPoseEstimation);
-
-       for (int n = 0; n < numberOfPoseEstimation; ++n) {
-               locations[n].x = poseEstimationResults.locations[n].x;
-               locations[n].y = poseEstimationResults.locations[n].y;
-       }
-
-       detected_cb(source, numberOfPoseEstimation, locations.data(), user_data);
-
-       return ret;
-}
+}
\ No newline at end of file
index db0fa7b..e5f8908 100644 (file)
 #define FLD_OPENCV_CONFIG_CAFFE_PATH \
        "/usr/share/capi-media-vision/models/FLD/caffe/fld_caffe_model_tweak.prototxt"
 
-//Pose Estimation
-#define PE_TFLITE_WEIGHT_PATH \
-       "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite"
-
 /******
  * Public model:
  *  IC: mobilenet caffe, tf?
@@ -2282,241 +2278,14 @@ int perform_facial_landmark_detection()
        return MEDIA_VISION_ERROR_NONE;
 }
 
-int perform_armnn_pose_estimation_detection(mv_engine_config_h *engine_cfg)
-{
-       int err = MEDIA_VISION_ERROR_NONE;
-
-       mv_engine_config_h handle = NULL;
-       err = mv_create_engine_config(&handle);
-       if (err != MEDIA_VISION_ERROR_NONE) {
-               printf("Fail to create engine configuration handle.\n");
-               if (handle) {
-                       int err2 = mv_destroy_engine_config(handle);
-                       if (err2 != MEDIA_VISION_ERROR_NONE) {
-                               printf("Fail to destroy engine cofniguration.\n");
-                       }
-               }
-               return err;
-       }
-
-       char *inputNodeName = "image";
-       char *outputNodeName[] = { "Convolutional_Pose_Machine/stage_5_out" };
-
-       mv_engine_config_set_string_attribute(
-                       handle, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH, PE_TFLITE_WEIGHT_PATH);
-
-       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_DATA_TYPE,
-                                                                          MV_INFERENCE_DATA_FLOAT32);
-
-       mv_engine_config_set_double_attribute(handle, MV_INFERENCE_MODEL_MEAN_VALUE,
-                                                                                 0.0);
-
-       mv_engine_config_set_double_attribute(handle, MV_INFERENCE_MODEL_STD_VALUE,
-                                                                                 1.0);
-
-       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_BACKEND_TYPE,
-                                                                          MV_INFERENCE_BACKEND_ARMNN);
-
-       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_TARGET_TYPE,
-                                                                          MV_INFERENCE_TARGET_CPU);
-
-       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_TENSOR_WIDTH,
-                                                                          192);
-
-       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_TENSOR_HEIGHT,
-                                                                          192);
-
-       mv_engine_config_set_int_attribute(handle,
-                                                                          MV_INFERENCE_INPUT_TENSOR_CHANNELS, 3);
-
-       mv_engine_config_set_string_attribute(handle, MV_INFERENCE_INPUT_NODE_NAME,
-                                                                                 inputNodeName);
-
-       mv_engine_config_set_array_string_attribute(
-                       handle, MV_INFERENCE_OUTPUT_NODE_NAMES, outputNodeName, 1);
-
-       *engine_cfg = handle;
-       return err;
-}
-
-int perform_pose_estimation_detection()
-{
-       int err = MEDIA_VISION_ERROR_NONE;
-
-       int sel_opt = 0;
-       const int options[] = { 1, 2, 3, 4, 5 };
-       const *names[] = { "Configuration", "ARMNN(CPU) + PoseEstimation",
-                                               "Prepare", "Run", "Back" };
-
-       mv_engine_config_h engine_cfg = NULL;
-       mv_inference_h infer = NULL;
-       mv_source_h mvSource = NULL;
-
-       while (sel_opt == 0) {
-               sel_opt = show_menu("Select Action:", options, names,
-                                                       ARRAY_SIZE(options));
-               switch (sel_opt) {
-               case 1: {
-                       //perform configuration
-                       if (engine_cfg) {
-                               int err2 = mv_destroy_engine_config(engine_cfg);
-                               if (err2 != MEDIA_VISION_ERROR_NONE)
-                                       printf("Fail to destroy engine_cfg [err:%i]\n", err2);
-                       }
-
-                       err = perform_configuration(&engine_cfg);
-               } break;
-               case 2: {
-                       //perform pose estimation config
-                       if (engine_cfg) {
-                               int err2 = mv_destroy_engine_config(engine_cfg);
-                               if (err2 != MEDIA_VISION_ERROR_NONE)
-                                       printf("Fail to destroy engine_cfg [err:%i]\n", err2);
-                       }
-                       err = perform_armnn_pose_estimation_detection(&engine_cfg);
-               } break;
-               case 3: {
-                       // create - configure - prepare
-                       if (infer) {
-                               int err2 = mv_inference_destroy(infer);
-                               if (err2 != MEDIA_VISION_ERROR_NONE) {
-                                       printf("Fail to destroy inference handle [err:%i]\n", err2);
-                               }
-                       }
-
-                       // inference
-                       // create handle
-                       err = mv_inference_create(&infer);
-                       if (err != MEDIA_VISION_ERROR_NONE) {
-                               printf("Fail to create inference handle [err:%i]\n", err);
-                               break;
-                       }
-
-                       //configure
-                       err = mv_inference_configure(infer, engine_cfg);
-                       if (err != MEDIA_VISION_ERROR_NONE) {
-                               printf("Fail to configure inference handle [err:%i]\n", err);
-                               break;
-                       }
-
-                       //prepare
-                       err = mv_inference_prepare(infer);
-                       if (err != MEDIA_VISION_ERROR_NONE) {
-                               printf("Fail to prepare inference handle");
-                               break;
-                       }
-               } break;
-               case 4: {
-                       if (mvSource) {
-                               int err2 = mv_destroy_source(mvSource);
-                               if (err2 != MEDIA_VISION_ERROR_NONE)
-                                       ;
-                               printf("Fail to destroy mvSource\n");
-                       }
-
-                       char *in_file_name = NULL;
-                       /* Load media source */
-                       while (input_string("Input file name to be inferred:", 1024,
-                                                               &(in_file_name)) == -1)
-                               printf("Incorrect input! Try again.\n");
-
-                       err = mv_create_source(&mvSource);
-                       if (err != MEDIA_VISION_ERROR_NONE) {
-                               printf("Fail to create mvSource.\n");
-                               free(in_file_name);
-                               break;
-                       }
-
-                       err = load_mv_source_from_file(in_file_name, mvSource);
-                       if (err != MEDIA_VISION_ERROR_NONE) {
-                               int err2 = mv_destroy_source(mvSource);
-                               if (err2 != MEDIA_VISION_ERROR_NONE) {
-                                       printf("Fail to destroy mvSource.\n", err2);
-                               }
-                               free(in_file_name);
-                               break;
-                       }
-                       free(in_file_name);
-
-                       struct timespec s_tspec;
-                       struct timespec e_tspec;
-
-                       clock_gettime(CLOCK_MONOTONIC, &s_tspec);
-
-                       // Pose estimation
-                       err = mv_inference_pose_estimation_detect(
-                                       mvSource, infer, NULL, _pose_estimation_detected_cb, NULL);
-
-                       clock_gettime(CLOCK_MONOTONIC, &e_tspec);
-
-                       struct timespec diffspec = diff(s_tspec, e_tspec);
-                       unsigned long timeDiff = gettotalmillisec(diffspec);
-                       printf("elased time : %lu(ms)\n", timeDiff);
-
-                       break;
-               }
-               case 5: {
-                       //perform destroy
-                       if (engine_cfg) {
-                               err = mv_destroy_engine_config(engine_cfg);
-                               if (err != MEDIA_VISION_ERROR_NONE) {
-                                       printf("Fail to destroy engine_cfg [err:%i]\n", err);
-                               }
-                       }
-
-                       if (infer) {
-                               err = mv_inference_destroy(infer);
-                               if (err != MEDIA_VISION_ERROR_NONE) {
-                                       printf("Fail to destroy inference handle [err:%i]\n", err);
-                               }
-                       }
-               } break;
-               default:
-                       printf("Invalid option.\n");
-                       sel_opt = 0;
-                       continue;
-               }
-
-               int do_another = 0;
-               if (err != MEDIA_VISION_ERROR_NONE) {
-                       printf("ERROR: Action is finished with error code: %i\n");
-               }
-
-               sel_opt = 0;
-               const int options_last[] = { 1, 2 };
-               const char *names_last[] = { "Yes", "No" };
-
-               while (sel_opt == 0) {
-                       sel_opt = show_menu(
-                                       "Run Pose Estimation Detection again?:", options_last,
-                                       names_last, ARRAY_SIZE(options_last));
-                       switch (sel_opt) {
-                       case 1:
-                               do_another = 1;
-                               break;
-                       case 2:
-                               do_another = 0;
-                               break;
-                       default:
-                               printf("Invalid option.\n");
-                               sel_opt = 0;
-                       }
-               }
-
-               sel_opt = (do_another == 1) ? 0 : 1;
-       }
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 int main()
 {
        int sel_opt = 0;
 
-       const int options[] = { 1, 2, 3, 4, 5, 6 };
+       const int options[] = { 1, 2, 3, 4, 5 };
        const char *names[] = { "Image Classification", "Object Detection",
                                                         "Face Detection",               "Facial LandmarkDetection",
-                                                        "Pose Estimation",              "Exit" };
+                                                        "Exit" };
 
        int err = MEDIA_VISION_ERROR_NONE;
        while (sel_opt == 0) {
@@ -2549,13 +2318,6 @@ int main()
                        break;
                }
                case 5: {
-                       err = perform_pose_estimation_detection();
-                       if (err != MEDIA_VISION_ERROR_NONE) {
-                               printf("Fail to perform pose estimation");
-                       }
-                       break;
-               }
-               case 6: {
                        printf("Exit");
                } break;
                default: