From: Inki Dae Date: Wed, 9 Aug 2023 06:16:22 +0000 (+0900) Subject: mv_machine_learning: add NVision object and face detections support X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_devel_vd;p=platform%2Fcore%2Fapi%2Fmediavision.git mv_machine_learning: add NVision object and face detections support Change-Id: I9e9b1e81152b83cf1931a85375e55b4bb841a2f5 Signed-off-by: Inki Dae --- diff --git a/mv_machine_learning/object_detection/meta/object_detection.json b/mv_machine_learning/object_detection/meta/object_detection.json index d1bdbf38..4e134273 100644 --- a/mv_machine_learning/object_detection/meta/object_detection.json +++ b/mv_machine_learning/object_detection/meta/object_detection.json @@ -14,7 +14,7 @@ { "name" : "DEFAULT_MODEL_NAME", "type" : "string", - "value" : "MOBILENET_V1_SSD" + "value" : "OD_PLUGIN" }, { "name" : "META_FILE_NAME", diff --git a/mv_machine_learning/object_detection/src/mv_object_detection.cpp b/mv_machine_learning/object_detection/src/mv_object_detection.cpp index a22245da..86b00d13 100644 --- a/mv_machine_learning/object_detection/src/mv_object_detection.cpp +++ b/mv_machine_learning/object_detection/src/mv_object_detection.cpp @@ -41,7 +41,7 @@ static mutex g_object_detection_mutex; int mv_object_detection_create(mv_object_detection_h *handle) { - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); MEDIA_VISION_NULL_ARG_CHECK(handle); MEDIA_VISION_FUNCTION_ENTER(); @@ -67,7 +67,7 @@ int mv_object_detection_create(mv_object_detection_h *handle) int mv_object_detection_destroy(mv_object_detection_h handle) { - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_FUNCTION_ENTER(); @@ -96,7 +96,7 @@ int mv_object_detection_set_model(mv_object_detection_h handle, const char *mode { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); @@ -121,7 +121,7 @@ int mv_object_detection_set_engine(mv_object_detection_h handle, const char *bac { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_NULL_ARG_CHECK(backend_type); @@ -148,7 +148,7 @@ int mv_object_detection_get_engine_count(mv_object_detection_h handle, unsigned { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_NULL_ARG_CHECK(engine_count); @@ -176,7 +176,7 @@ int mv_object_detection_get_engine_type(mv_object_detection_h handle, const unsi { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_NULL_ARG_CHECK(engine_type); @@ -204,7 +204,7 @@ int mv_object_detection_get_device_count(mv_object_detection_h handle, const cha { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_NULL_ARG_CHECK(device_count); @@ -232,7 +232,7 @@ int mv_object_detection_get_device_type(mv_object_detection_h handle, const char { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_NULL_ARG_CHECK(engine_type); @@ -260,7 +260,7 @@ int mv_object_detection_configure(mv_object_detection_h handle) { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_FUNCTION_ENTER(); @@ -284,7 +284,7 @@ int mv_object_detection_prepare(mv_object_detection_h handle) { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_FUNCTION_ENTER(); @@ -308,7 +308,7 @@ int mv_object_detection_inference(mv_object_detection_h handle, mv_source_h sour { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_INSTANCE_CHECK(source); @@ -337,7 +337,7 @@ int mv_object_detection_inference_async(mv_object_detection_h handle, mv_source_ { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_INSTANCE_CHECK(source); MEDIA_VISION_INSTANCE_CHECK(completion_cb); @@ -367,7 +367,7 @@ int mv_object_detection_get_result(mv_object_detection_h handle, unsigned int *n { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_INSTANCE_CHECK(number_of_objects); MEDIA_VISION_INSTANCE_CHECK(indices); @@ -405,7 +405,7 @@ int mv_object_detection_get_label(mv_object_detection_h handle, const unsigned i { lock_guard lock(g_object_detection_mutex); - MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); + //MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported()); MEDIA_VISION_INSTANCE_CHECK(handle); MEDIA_VISION_INSTANCE_CHECK(label); diff --git a/packaging/capi-media-vision.spec b/packaging/capi-media-vision.spec index 6a8dd1fc..5a9c3893 100644 --- a/packaging/capi-media-vision.spec +++ b/packaging/capi-media-vision.spec @@ -46,6 +46,7 @@ BuildRequires: pkgconfig(grpc++) %if "%{tizen_profile_name}" == "tv" %define enable_ml_face_recognition 0 %define build_depth_stream_testsuite 0 +%define enable_ml_object_detection 1 %else %define enable_ml_face_recognition 1 BuildRequires: pkgconfig(training-engine-interface-common) diff --git a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp index a82e3d9c..65b4af1f 100644 --- a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp +++ b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp @@ -206,6 +206,63 @@ TEST(ObjectDetectionTest, InferenceShouldBeOk) ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); } +TEST(NVisionObjectDetectionTest, InferenceShouldBeOk) +{ + mv_object_detection_h handle; + vector test_model_names = { "OD_PLUGIN", "FD_PLUGIN" }; + + mv_source_h mv_source = NULL; + int ret = mv_create_source(&mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + ret = ImageHelper::loadImageToSource(IMG_DOG, mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + for (auto &model_name : test_model_names) { + ret = mv_object_detection_create(&handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + mv_object_detection_set_model(handle, model_name.c_str(), NULL, NULL, NULL); + + ret = mv_object_detection_configure(handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + ret = mv_object_detection_prepare(handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + ret = mv_object_detection_inference(handle, mv_source); + ASSERT_EQ(ret, 0); + + unsigned int number_of_objects; + const int *left, *top, *right, *bottom; + const unsigned int *indices; + const float *confidences; + + ret = mv_object_detection_get_result(handle, &number_of_objects, &indices, &confidences, &left, &top, &right, + &bottom); + ASSERT_EQ(ret, 0); + + for (unsigned int idx = 0; idx < number_of_objects; ++idx) { + cout << "index = " << indices[idx] << " probability = " << confidences[idx] << " " << left[idx] << " x " + << top[idx] << " ~ " << right[idx] << " x " << bottom[idx] << endl; + } + + for (unsigned int idx = 0; idx < number_of_objects; ++idx) { + const char *label; + + ret = mv_object_detection_get_label(handle, indices[idx], &label); + ASSERT_EQ(ret, 0); + cout << "index = " << indices[idx] << " label = " << label << endl; + } + + ret = mv_object_detection_destroy(handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + } + + ret = mv_destroy_source(mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); +} + TEST(FaceDetectionTest, InferenceShouldBeOk) { mv_object_detection_h handle;