mv_machine_learning: code refactoring to mv_inference_open
authorInki Dae <inki.dae@samsung.com>
Tue, 17 May 2022 10:15:19 +0000 (19:15 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 20 Jul 2022 05:16:40 +0000 (14:16 +0900)
[Version] : 0.21.5-0
[Issue type] : code refactoring

Did code refactoring to mv_inference_open.cpp file by moving
IsTargetDeviceSupported function to Inference class because
this function is valid only after Bind call. So no reason
for mv_inference_open.cpp to call IsTargetDeviceSupport function
to check if a given device type is valid or not.

And configure backend type as soon as getting the backend type from
the default ini file.

Change-Id: I5d51fb7c71fc737d111f0058e2b1c3ddf1ebf75f
Signed-off-by: Inki Dae <inki.dae@samsung.com>
mv_machine_learning/inference/include/Inference.h
mv_machine_learning/inference/src/Inference.cpp
mv_machine_learning/inference/src/mv_inference_open.cpp
packaging/capi-media-vision.spec

index bac4265f40929593366ed754da3526c1519c2a5b..e2f7ef089be71542b99716b65118388e38da96cf 100644 (file)
@@ -182,13 +182,6 @@ namespace inference
                 */
                int ConfigureTargetDevices(const int targetDevices);
 
-               /**
-                * @brief   Check supported target devices
-                *
-                * @since_tizen 6.5
-                */
-               bool IsTargetDeviceSupported(const int targetDevices);
-
                /**
                 * @brief   Configure the maximum number of inference results
                 *
@@ -359,6 +352,7 @@ namespace inference
 
        private:
                void CheckSupportedInferenceBackend();
+               bool IsTargetDeviceSupported(const int targetDevices);
                int ConvertEngineErrorToVisionError(int error);
                int ConvertTargetTypes(int given_types);
                int ConvertToCv(int given_type);
index 3d9b5b4b55d14c1ec43bdcd379786b25fadc97fb..157d03efb0cb6aa77e93d41658843bb00db2150f 100755 (executable)
@@ -839,6 +839,12 @@ namespace inference
                        return ret;
                }
 
+               if (!IsTargetDeviceSupported(mConfig.mTargetTypes)) {
+                       mBackend->UnbindBackend();
+                       LOGE("Tried to configure invalid target types.");
+                       return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+               }
+
                LOGI("LEAVE");
 
                return MEDIA_VISION_ERROR_NONE;
index e56a9ff865db992befb7e1252d3f52958837a421..ac8f857fa55d6d5b7ffb578ed123450342237b63 100644 (file)
@@ -355,17 +355,17 @@ int mv_inference_configure_engine_open(mv_inference_h infer,
                goto out_of_function;
        }
 
-       ret = mv_engine_config_get_int_attribute(
-                       engine_config, MV_INFERENCE_TARGET_DEVICE_TYPE, &targetTypes);
+       ret = pInfer->ConfigureBackendType(
+                       (mv_inference_backend_type_e) backendType);
        if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference target type");
+               LOGE("Fail to configure a backend type.");
                goto out_of_function;
        }
 
-       ret = pInfer->ConfigureBackendType(
-                       (mv_inference_backend_type_e) backendType);
+       ret = mv_engine_config_get_int_attribute(
+                       engine_config, MV_INFERENCE_TARGET_DEVICE_TYPE, &targetTypes);
        if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to configure a backend type.");
+               LOGE("Fail to get inference target type");
                goto out_of_function;
        }
 
@@ -397,11 +397,6 @@ int mv_inference_configure_engine_open(mv_inference_h infer,
                goto out_of_function;
        }
 
-       if (!pInfer->IsTargetDeviceSupported(targetTypes)) {
-               ret = MEDIA_VISION_ERROR_NOT_SUPPORTED;
-               LOGE("Tried to configure invalid target types.");
-       }
-
 out_of_function:
        LOGI("LEAVE");
 
index 9fb61cbe307f0fa5a798fbf8f429e99bf0295b5f..ca040d78bf46eaf07872a226682bb7c0d6ecf5fb 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.21.4
+Version:     0.21.5
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause