From: Hyunsoo Park Date: Tue, 26 Apr 2022 04:26:05 +0000 (+0900) Subject: mv_machine_learning:code clean up X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc6e3a157060a5c60f7da1995e8cdcf51014b97d;p=platform%2Fcore%2Fapi%2Fmediavision.git mv_machine_learning:code clean up [Version] : 0.20.1-0 [Issue type] : Clean Up Change-Id: Ia244c2217a6a2a5fd6b6a3c145ceb7e5836feb67 Signed-off-by: Hyunsoo Park --- diff --git a/include/mv_tracker.h b/include/mv_tracker.h index 4edf4cb4..2be047fa 100644 --- a/include/mv_tracker.h +++ b/include/mv_tracker.h @@ -62,70 +62,6 @@ int mv_tracker_create(mv_tracker_h *handle, int x, int y, int w, int h); */ int mv_tracker_destroy(mv_tracker_h handle); -/** - * @brief Prepare the resources for tracker. - * @details Use this function to prepare the resources for tracker. - * - * @since_tizen 7.0 - * - * @param[in] handle The handle to the inference - * - * @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_KEY_NOT_AVAILABLE Attribute key isn't available - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create tracker handle by using mv_tracker_create() - */ -int mv_tracker_prepare(mv_tracker_h handle); - -/** - * @brief Register a new tracker on the @a source - * @details Use this function to register a new tracker. - * Each time when this function is called, a new tracker on the media source - * will be registered to internal database. - * - * @since_tizen 7.0 - * - * @param [in] handle The handle to the tracker object. - * @param [in] source The handle to the source of the media. - * @param [in] label The label to be registered. (the maximum length of the label array is 256 words) - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Prepare an tracker by calling @ref mv_tracker_prepare() - */ -int mv_tracker_register(mv_tracker_h handle, mv_source_h source, const char *label); - -/** - * @brief Unregister a new tracker on the @a source - * @details Use this function to unregister a given label. - * Each time when this function is called, all data related to the label - * will be removed from internal database. - * - * @since_tizen 7.0 - * - * @param [in] handle The handle to the tracker object. - * @param [in] label The label to be unregistered. (the maximum length of the label array is 256 words) - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * - * @pre Register an new tracker by calling @ref mv_tracker_register() - */ -int mv_tracker_unregister(mv_tracker_h handle, const char *label); - /** * @brief Inference with a given tracker on the @a source * @details Use this function to inference with a given source. diff --git a/inference_engine.ini b/inference_engine.ini deleted file mode 100644 index 6de0a603..00000000 --- a/inference_engine.ini +++ /dev/null @@ -1,3 +0,0 @@ -[inference backend] -;/*OPENCV=0, Tensorflow-lite=1 -supported backend types = 0,1,2,3,4,5,6 diff --git a/mv_machine_learning/tracker/include/mv_tracker_open.h b/mv_machine_learning/tracker/include/mv_tracker_open.h index 8036576e..a5eb8461 100644 --- a/mv_machine_learning/tracker/include/mv_tracker_open.h +++ b/mv_machine_learning/tracker/include/mv_tracker_open.h @@ -22,54 +22,21 @@ #include "mv_tracker.h" #include "mv_tracker_type.h" -/** - * @brief Defines #MV_TRACKER_BACKBONE_MODEL_FILE_PATH - * to set the backbone model file path. - * @details This model file is used to extract the feature vectors from a given face image data. - * - * @since_tizen 7.0 - * @see mv_engine_config_set_string_attribute() - * @see mv_engine_config_get_string_attribute() - */ -#define MV_TRACKER_BACKBONE_MODEL_FILE_PATH "MV_TRACKER_BACKBONE_MODEL_FILE_PATH" - -/** - * @brief Defines #MV_TRACKER_DEFAULT_PATH - * to set the path where the training relevant files are created. - * @details This path is used as a default location where the trained model, label and feature vector files are created. - * - * @since_tizen 7.0 - * @see mv_engine_config_set_string_attribute() - * @see mv_engine_config_get_string_attribute() - */ -#define MV_TRACKER_DEFAULT_PATH "MV_TRACKER_DEFAULT_PATH" - -/** - * @brief Defines #MV_TRACKER_DECISION_THRESHOLD - * to set the decision threshold file+. - * @details This file is used to determine face recognition result with a given face image data is true or false.. - * - * @since_tizen 7.0 - * @see mv_engine_config_set_string_attribute() - * @see mv_engine_config_get_string_attribute() - */ -#define MV_TRACKER_DECISION_THRESHOLD "MV_TRACKER_DECISION_THRESHOLD" - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @brief Create face recognition object handle. - * @details Use this function to create an face recognition object handle. - * After creation the handle has to be prepared with - * @ref mv_tracker_prepare_open() function to prepare - * an face recognition object. + * @brief Create tracker object handle. + * @details Use this function to create an tracker object handle. + * After creation the handle has to be performed with + * @ref mv_tracker_perform_open() function to perform + * an tracker object. * * @since_tizen 7.0 * - * @param [out] handle The handle to the face recognition object to be created + * @param [out] handle The handle to the tracker object to be created * * @return @c 0 on success, otherwise a negative error value * @retval #MEDIA_VISION_ERROR_NONE Successful @@ -85,114 +52,32 @@ extern "C" int mv_tracker_create_open(mv_tracker_h *out_handle, int x, int y, int w, int h); /** - * @brief Destroy face recognition handle and releases all its resources. + * @brief Destroy tracker handle and releases all its resources. * * @since_tizen 7.0 * - * @param [in] handle The handle to the face recognition object to be destroyed. + * @param [in] handle The handle to the tracker object to be destroyed. * * @return @c 0 on success, otherwise a negative error value * @retval #MEDIA_VISION_ERROR_NONE Successful * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre Create an face recognition handle by using @ref mv_tracker_create_open() + * @pre Create an tracker handle by using @ref mv_tracker_create_open() * * @see mv_tracker_create_open() */ int mv_tracker_destroy_open(mv_tracker_h handle); /** - * @brief Configure face recognition. - * - * @since_tizen 7.0 - * - * @param [in] handle The handle to the face recognition object created. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create an face recognition handle by using @ref mv_tracker_create_open() - * - * @see mv_tracker_create_open() - */ - int mv_tracker_configure(mv_tracker_h handle); - - /** - * @brief Prepare face recognition. - * - * @since_tizen 7.0 - * - * @param [in] handle The handle to the face recognition object to be prepared. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create an face recognition handle by using @ref mv_tracker_create_open() - * - * @see mv_tracker_create_open() - */ - int mv_tracker_prepare_open(mv_tracker_h handle); - - /** - * @brief Register a new face on the @a source - * @details Use this function to register a new face. - * Each time when this function is called, a new face on the media source - * will be registered to internal database. - * - * @since_tizen 7.0 - * - * @param [in] handle The handle to the face recognition object. - * @param [in] source The handle to the source of the media. - * @param [in] label The label to be registered. (the maximum length of the label array is 256 words) - * - * @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_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @pre Create a source handle by calling @ref mv_create_source() - * @pre Create an face recognition handle by calling @ref mv_tracker_create_open() - * @pre Prepare an face recognition by calling @ref mv_tracker_prepare_open() - */ - int mv_tracker_register_open(mv_tracker_h handle, mv_source_h source, const char *label); - - /** - * @brief Unregister a new face on the @a source - * @details Use this function to unregister a given label. - * Each time when this function is called, all data related to the label - * will be removed from internal database. - * - * @since_tizen 7.0 - * - * @param [in] handle The handle to the face recognition object. - * @param [in] label The label to be registered. (the maximum length of the label array is 256 words) - * - * @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_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @pre Create an face recognition handle by calling @ref mv_tracker_create_open() - * @pre Prepare an face recognition by calling @ref mv_tracker_prepare_open() - */ - int mv_tracker_unregister_open(mv_tracker_h handle, const char *label); - - /** - * @brief Inference with a given face on the @a source - * @details Use this function to inference with a given source. - * This function returns an proper label string to a give source. + * @brief Track with a given roi on the @a source + * @details Use this function to track with a given source. + * This function returns an proper roi to a give source. * * @since_tizen 7.0 * - * @param [in] handle The handle to the face recognition object. + * @param [in] handle The handle to the tracker object. * @param [in] source The handle to the source of the media. - * @param [out] out_result The structure which is filled with inference result, + * @param [out] out_result The structure which is filled with track result, * * @return @c 0 on success, otherwise a negative error value * @retval #MEDIA_VISION_ERROR_NONE Successful @@ -202,9 +87,7 @@ extern "C" * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory * * @pre Create a source handle by calling @ref mv_create_source() - * @pre Create an face recognition handle by calling @ref mv_tracker_create_open() - * @pre Prepare an face recognition by calling @ref mv_tracker_prepare_open() - * @pre Register a new face by calling @ref mv_tracker_register_open() + * @pre Create an tracker handle by calling @ref mv_tracker_create_open() */ int mv_tracker_perform_open(mv_tracker_h handle, mv_source_h source, mv_tracker_result_s *out_result); @@ -213,4 +96,4 @@ extern "C" } #endif /* __cplusplus */ -#endif /* __MEDIA_VISION_INFERENCE_OPEN_H__ */ +#endif /* __MEDIA_VISION_track_OPEN_H__ */ diff --git a/mv_machine_learning/tracker/src/mv_tracker.c b/mv_machine_learning/tracker/src/mv_tracker.c index 01e6c173..1f0191f3 100644 --- a/mv_machine_learning/tracker/src/mv_tracker.c +++ b/mv_machine_learning/tracker/src/mv_tracker.c @@ -54,63 +54,6 @@ int mv_tracker_destroy(mv_tracker_h handle) return ret; } -int mv_tracker_prepare(mv_tracker_h handle) -{ - MEDIA_VISION_SUPPORT_CHECK( - __mv_inference_face_check_system_info_feature_supported()); - - MEDIA_VISION_INSTANCE_CHECK(handle); - - MEDIA_VISION_FUNCTION_ENTER(); - - int ret = MEDIA_VISION_ERROR_NONE; - - ret = mv_tracker_prepare_open(handle); - - MEDIA_VISION_FUNCTION_LEAVE(); - - return ret; -} - -int mv_tracker_register(mv_tracker_h handle, mv_source_h source, const char *label) -{ - MEDIA_VISION_SUPPORT_CHECK( - __mv_inference_face_check_system_info_feature_supported()); - - MEDIA_VISION_INSTANCE_CHECK(handle); - MEDIA_VISION_INSTANCE_CHECK(source); - MEDIA_VISION_INSTANCE_CHECK(label); - - MEDIA_VISION_FUNCTION_ENTER(); - - int ret = MEDIA_VISION_ERROR_NONE; - - ret = mv_tracker_register_open(handle, source, label); - - MEDIA_VISION_FUNCTION_LEAVE(); - - return ret; -} - -int mv_tracker_unregister(mv_tracker_h handle, const char *label) -{ - MEDIA_VISION_SUPPORT_CHECK( - __mv_inference_face_check_system_info_feature_supported()); - - MEDIA_VISION_INSTANCE_CHECK(handle); - MEDIA_VISION_INSTANCE_CHECK(label); - - MEDIA_VISION_FUNCTION_ENTER(); - - int ret = MEDIA_VISION_ERROR_NONE; - - ret = mv_tracker_unregister_open(handle, label); - - MEDIA_VISION_FUNCTION_LEAVE(); - - return ret; -} - int mv_tracker_perform(mv_tracker_h handle, mv_source_h source, mv_tracker_result_s *out_result) { diff --git a/mv_machine_learning/tracker/src/mv_tracker_open.cpp b/mv_machine_learning/tracker/src/mv_tracker_open.cpp index 95dff8b7..bc67c59e 100644 --- a/mv_machine_learning/tracker/src/mv_tracker_open.cpp +++ b/mv_machine_learning/tracker/src/mv_tracker_open.cpp @@ -61,41 +61,6 @@ int mv_tracker_destroy_open(mv_tracker_h handle) return MEDIA_VISION_ERROR_NONE; } -int mv_tracker_configure(mv_tracker_h handle) -{ - LOGD("ENTER"); - - LOGD("LEAVE"); - - return MEDIA_VISION_ERROR_NONE; -} - -int mv_tracker_prepare_open(mv_tracker_h handle) -{ - LOGD("ENTER"); - - LOGD("LEAVE"); - - return MEDIA_VISION_ERROR_NONE; -} - -int mv_tracker_register_open(mv_tracker_h handle, mv_source_h source, const char *label) -{ - LOGD("ENTER"); - - LOGD("LEAVE"); - - return MEDIA_VISION_ERROR_NONE; -} - -int mv_tracker_unregister_open(mv_tracker_h handle, const char *label) -{ - LOGD("ENTER"); - LOGD("LEAVE"); - - return MEDIA_VISION_ERROR_NONE; -} - int mv_tracker_perform_open(mv_tracker_h handle, mv_source_h source, mv_tracker_result_s *results) { @@ -203,11 +168,11 @@ int mv_tracker_perform_open(mv_tracker_h handle, mv_source_h source, } else if( pTracker->initialized ) { - LOGD(" pTracker->initialized "); + LOGD("pTracker->initialized "); //updates the tracker if( pTracker->tracker->update(frame, pTracker->boundingBox) ) { - LOGD(" pTracker->tracker->update "); + LOGD("pTracker->tracker->update "); //rectangle( image, boundingBox, Scalar( 255, 0, 0 ), 2, 1 ); results->coords[0] = pTracker->boundingBox.x; results->coords[1] = pTracker->boundingBox.y ; diff --git a/test/testsuites/machine_learning/tracker/test_tracker.cpp b/test/testsuites/machine_learning/tracker/test_tracker.cpp index 074413b9..777cf364 100644 --- a/test/testsuites/machine_learning/tracker/test_tracker.cpp +++ b/test/testsuites/machine_learning/tracker/test_tracker.cpp @@ -29,123 +29,11 @@ using namespace MediaVision::Common; TEST(TrackerTest, TrackerClassShouldBeOk) { - // mv_tracker_h handle; int ret = MEDIA_VISION_ERROR_NONE; - // // int ret = mv_tracker_create(&handle,1,2,3,4); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - // ret = mv_tracker_prepare(handle); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // // for (auto& image : training_images) { - // // const string image_path = string("/usr/share/capi-media-vision/face-recognition/images/training/") + image.first; - // const string image_path = string("/usr/share/capi-media-vision/face-recognition/images/training/"); - // mv_source_h mv_source = NULL; - - // ret = mv_create_source(&mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // ret = ImageHelper::loadImageToSource(image_path.c_str(), mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // // ret = mv_tracker_register(handle, mv_source, image.second.c_str()); - // ASSERT_EQ(ret, 0); - - // ret = mv_destroy_source(mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - // // } - - // // unsigned int image_idx = 0; - - // // for (auto& image : test_images) { - // // const string image_path = string("/usr/share/capi-media-vision/face-recognition/images/test/") + image.first; - - // ret = mv_create_source(&mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // ret = ImageHelper::loadImageToSource(image_path.c_str(), mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // mv_tracker_result_s result; - - // ret = mv_tracker_perform(handle, mv_source, &result); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // ret = mv_destroy_source(mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // // ASSERT_EQ(answers[image_idx++], string(result.label)); - // //} - - // ret = mv_tracker_destroy(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); } -TEST(FaceRecognitionTest, FaceRecognitionClassWithEachLabelRemovalShouldBeOk) -{ - int ret = MEDIA_VISION_ERROR_NONE; - // mv_tracker_h handle; - // // int ret = mv_tracker_create(&handle,1,2,3,4); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // ret = mv_tracker_prepare(handle); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // // auto& answer = answers[label_idx++]; - // // unsigned int image_idx = 0; - - // // for (auto& image : training_images) { - // // const string image_path = string("/usr/share/capi-media-vision/face-recognition/images/training/") + image.first; - // const string image_path = string("/usr/share/capi-media-vision/face-recognition/images/training/"); - // mv_source_h mv_source = NULL; - // ret = mv_create_source(&mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // ret = ImageHelper::loadImageToSource(image_path.c_str(), mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // // ret = mv_tracker_register(handle, mv_source, image.second.c_str()); - // ASSERT_EQ(ret, 0); - - // ret = mv_destroy_source(mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - // // } - - - // // if (!label.empty()) { - // // ret = mv_tracker_unregister(handle, label.c_str()); - // // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - // // } - - // // for (auto& image : test_images) { - // // const string image_path = string("/usr/share/capi-media-vision/face-recognition/images/test/") + image.first; - - // ret = mv_create_source(&mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // ret = ImageHelper::loadImageToSource(image_path.c_str(), mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // mv_tracker_result_s result; - - // ret = mv_tracker_perform(handle, mv_source, &result); - // if (ret == MEDIA_VISION_ERROR_NO_DATA) { - // // strcpy(result.label, "none"); - // ret = MEDIA_VISION_ERROR_NONE; - // } - - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // ret = mv_destroy_source(mv_source); - // ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - // // ASSERT_EQ(answer[image_idx++], string(result.label)); - // // } - - // // ret = mv_tracker_destroy(handle); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); -} - int main(int argc, char **argv) { InitGoogleTest(&argc, argv);