mv_machine_learning: reallocate parser on changing meta file
[platform/core/api/mediavision.git] / mv_machine_learning / landmark_detection / src / landmark_detection_config.cpp
index 90c9767..5974432 100644 (file)
@@ -29,14 +29,7 @@ namespace mediavision
 namespace machine_learning
 {
 LandmarkDetectionConfig::LandmarkDetectionConfig()
-{
-       _parser = make_unique<LandmarkDetectionParser>();
-}
-
-void LandmarkDetectionConfig::setTaskType(LandmarkDetectionTaskType task_type)
-{
-       _task_type = task_type;
-}
+{}
 
 void LandmarkDetectionConfig::setBackendType(int backend_type)
 {
@@ -48,11 +41,6 @@ void LandmarkDetectionConfig::setTargetDeviceType(int device_type)
        _targetDeviceType = device_type;
 }
 
-LandmarkDetectionTaskType LandmarkDetectionConfig::getTaskType() const
-{
-       return _task_type;
-}
-
 const std::string &LandmarkDetectionConfig::getDefaultModelName() const
 {
        return _defaultModelName;
@@ -97,9 +85,9 @@ void LandmarkDetectionConfig::setUserModel(const string &model_file, const strin
 {
        if (!model_file.empty())
                _modelFilePath = _modelDefaultPath + model_file;
-       if (meta_file.empty())
+       if (!meta_file.empty())
                _modelMetaFilePath = _modelDefaultPath + meta_file;
-       if (label_file.empty())
+       if (!label_file.empty())
                _modelLabelFilePath = _modelDefaultPath + label_file;
 }
 
@@ -152,8 +140,6 @@ void LandmarkDetectionConfig::parseConfigFile(const std::string &configFilePath)
        _modelMetaFilePath = _modelDefaultPath + _modelMetaFilePath;
        LOGI("meta file path = %s", _modelMetaFilePath.c_str());
 
-       _parser->load(_modelMetaFilePath);
-
        ret = config->getDoubleAttribute(MV_LANDMARK_DETECTION_CONFIDENCE_THRESHOLD, &_confidence_threshold);
        if (ret != MEDIA_VISION_ERROR_NONE)
                LOGW("threshold value doesn't exist.");
@@ -171,5 +157,12 @@ void LandmarkDetectionConfig::parseConfigFile(const std::string &configFilePath)
        LOGI("label file path = %s", _modelLabelFilePath.c_str());
 }
 
+void LandmarkDetectionConfig::loadMetaFile(LandmarkDetectionTaskType task_type)
+{
+       _parser = make_unique<LandmarkDetectionParser>();
+       _parser->setTaskType(static_cast<int>(task_type));
+       _parser->load(_modelMetaFilePath);
+}
+
 }
 }
\ No newline at end of file