Fix : Enable overriding of default backend parameters 23/321323/3
authorBhuvan Reddy Gangula <bhu1.gangula@samsung.com>
Fri, 21 Mar 2025 07:29:24 +0000 (16:29 +0900)
committerBhuvan Reddy Gangula <bhu1.gangula@samsung.com>
Tue, 25 Mar 2025 02:22:42 +0000 (11:22 +0900)
Even though there are functions to set backend engine,device , they are overriden
by the default configuration file values in the configure() function of object_detection.cpp

Implemented a check before overriding

Change-Id: I087a634e5c5ac72697dea00e474a843cdbb68998
Signed-off-by: Bhuvan Reddy Gangula <bhu1.gangula@samsung.com>
mv_machine_learning/object_detection/src/object_detection.cpp

index 5f3935982a7e1a227030109988f4d94899056911..8b45e2a97fc8e71f13a9f77a78ce9640c4e816f4 100644 (file)
@@ -37,7 +37,9 @@ namespace mediavision
 namespace machine_learning
 {
 ObjectDetection::ObjectDetection(ObjectDetectionTaskType task_type)
-               : _task_type(task_type), _backendType(), _targetDeviceType()
+               : _task_type(task_type)
+               , _backendType(MV_INFERENCE_BACKEND_NONE)
+               , _targetDeviceType(MV_INFERENCE_TARGET_DEVICE_NONE)
 {
        _inference = make_unique<Inference>();
        _parser = make_unique<ObjectDetectionParser>();
@@ -196,13 +198,19 @@ void ObjectDetection::parseMetaFile(string meta_file_name)
 {
        _config = make_unique<EngineConfig>(string(MV_CONFIG_PATH) + meta_file_name);
 
-       int ret = _config->getIntegerAttribute(string(MV_OBJECT_DETECTION_BACKEND_TYPE), &_backendType);
-       if (ret != MEDIA_VISION_ERROR_NONE)
-               throw InvalidOperation("Fail to get backend engine type.");
+       int ret;
 
-       ret = _config->getIntegerAttribute(string(MV_OBJECT_DETECTION_TARGET_DEVICE_TYPE), &_targetDeviceType);
-       if (ret != MEDIA_VISION_ERROR_NONE)
-               throw InvalidOperation("Fail to get target device type.");
+       if (_backendType == MV_INFERENCE_BACKEND_NONE) {
+               ret = _config->getIntegerAttribute(string(MV_OBJECT_DETECTION_BACKEND_TYPE), &_backendType);
+               if (ret != MEDIA_VISION_ERROR_NONE)
+                       throw InvalidOperation("Fail to get backend engine type.");
+       }
+
+       if (_targetDeviceType == MV_INFERENCE_TARGET_DEVICE_NONE) {
+               ret = _config->getIntegerAttribute(string(MV_OBJECT_DETECTION_TARGET_DEVICE_TYPE), &_targetDeviceType);
+               if (ret != MEDIA_VISION_ERROR_NONE)
+                       throw InvalidOperation("Fail to get target device type.");
+       }
 
        ret = _config->getStringAttribute(MV_OBJECT_DETECTION_MODEL_DEFAULT_PATH, &_modelDefaultPath);
        if (ret != MEDIA_VISION_ERROR_NONE)