mv_machine_learning: add NVision object and face detections support tizen_devel_vd
authorInki Dae <inki.dae@samsung.com>
Wed, 9 Aug 2023 06:16:22 +0000 (15:16 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 9 Aug 2023 06:16:22 +0000 (15:16 +0900)
Change-Id: I9e9b1e81152b83cf1931a85375e55b4bb841a2f5
Signed-off-by: Inki Dae <inki.dae@samsung.com>
mv_machine_learning/object_detection/meta/object_detection.json
mv_machine_learning/object_detection/src/mv_object_detection.cpp
packaging/capi-media-vision.spec
test/testsuites/machine_learning/object_detection/test_object_detection.cpp

index d1bdbf38851d3c7b9b470ac652bac41604a433a6..4e134273938789b099a2e15ba7e689ebaaab58f1 100644 (file)
@@ -14,7 +14,7 @@
         {
             "name"  : "DEFAULT_MODEL_NAME",
             "type"  : "string",
-            "value" : "MOBILENET_V1_SSD"
+            "value" : "OD_PLUGIN"
         },
         {
             "name"  : "META_FILE_NAME",
index a22245daad84d374d5c4e250b33d3a260f01b704..86b00d13ecdc227c0acb55a73105adfb42423cf8 100644 (file)
@@ -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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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<mutex> 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);
 
index 6a8dd1fceaaa754bc736d85be49f2c7dbd9afa77..5a9c3893489ec8729dcaec803cf125b91e6e0eed 100644 (file)
@@ -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)
index a82e3d9cdc4b7e3e8c146ea901f7602175c96944..65b4af1f890fdd6c2db9d37d4afbbc50f3184a0e 100644 (file)
@@ -206,6 +206,63 @@ TEST(ObjectDetectionTest, InferenceShouldBeOk)
        ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
 }
 
+TEST(NVisionObjectDetectionTest, InferenceShouldBeOk)
+{
+       mv_object_detection_h handle;
+       vector<string> 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;