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>();
{
_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)