Fix nested condition and formatting 57/283957/2
authorKwanghoon Son <k.son@samsung.com>
Tue, 8 Nov 2022 01:05:24 +0000 (20:05 -0500)
committerkwang son <k.son@samsung.com>
Wed, 9 Nov 2022 02:15:15 +0000 (02:15 +0000)
[Issue type] refactoring

Change-Id: I59b02a9b61d993dce502cda7f482fa30cfc9ce63
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
mv_machine_learning/inference/src/OutputMetadata.cpp

index 4508856..46db01e 100644 (file)
@@ -31,7 +31,7 @@ namespace mediavision
 {
 namespace inference
 {
-int OutputMetadata::ParseScore(JsonObject *root, LayerInfolayer)
+int OutputMetadata::ParseScore(JsonObject *root, LayerInfo &layer)
 {
        if (!json_object_has_member(root, "score")) {
                LOGI("No score outputmetadata");
@@ -48,7 +48,7 @@ int OutputMetadata::ParseScore(JsonObject *root, LayerInfo& layer)
        return ret;
 }
 
-int OutputMetadata::ParseBox(JsonObject *root, LayerInfolayer)
+int OutputMetadata::ParseBox(JsonObject *root, LayerInfo &layer)
 {
        if (!json_object_has_member(root, "box")) {
                LOGI("No box outputmetadata");
@@ -65,7 +65,7 @@ int OutputMetadata::ParseBox(JsonObject *root, LayerInfo& layer)
        return ret;
 }
 
-int OutputMetadata::ParseLandmark(JsonObject *root, LayerInfolayer)
+int OutputMetadata::ParseLandmark(JsonObject *root, LayerInfo &layer)
 {
        LOGI("ENTER");
 
@@ -82,7 +82,7 @@ int OutputMetadata::ParseLandmark(JsonObject *root, LayerInfo& layer)
        return MEDIA_VISION_ERROR_NONE;
 }
 
-int OutputMetadata::ParseOffset(JsonObject *root, LayerInfolayer)
+int OutputMetadata::ParseOffset(JsonObject *root, LayerInfo &layer)
 {
        LOGI("ENTER");
 
@@ -99,7 +99,7 @@ int OutputMetadata::ParseOffset(JsonObject *root, LayerInfo& layer)
        return MEDIA_VISION_ERROR_NONE;
 }
 
-int OutputMetadata::GetPostProcess(JsonObject *root, LayerInfolayer)
+int OutputMetadata::GetPostProcess(JsonObject *root, LayerInfo &layer)
 {
        LOGI("ENTER");
 
@@ -128,16 +128,14 @@ int OutputMetadata::GetPostProcess(JsonObject *root, LayerInfo& layer)
                                LOGE("Fail to GetBoxDecodeInfo[%d]", ret);
                                return ret;
                        }
-
-                       if (box.GetDecodingType() == INFERENCE_BOX_DECODING_TYPE_SSD_ANCHOR) {
-                               ret = box.GetDecodeInfo().GenerateAnchor();
-                               if (ret != MEDIA_VISION_ERROR_NONE) {
-                                       LOGE("Fail to GenerateAnchor[%d]", ret);
-                                       return ret;
-                               }
+               }
+               if (box.GetDecodingType() == INFERENCE_BOX_DECODING_TYPE_SSD_ANCHOR) {
+                       ret = box.GetDecodeInfo().GenerateAnchor();
+                       if (ret != MEDIA_VISION_ERROR_NONE) {
+                               LOGE("Fail to GenerateAnchor[%d]", ret);
+                               return ret;
                        }
                }
-
        }
 
        if (json_object_has_member(object, "label")) {
@@ -222,12 +220,12 @@ int OutputMetadata::Parse(JsonObject *root, std::string key_name)
 
        for (auto idx = 0; idx < json_array_get_length(outputList); ++idx) {
                JsonNode *output_node = json_array_get_element(outputList, idx);
-           std::string token(json_to_string(output_node, 1));
+               std::string token(json_to_string(output_node, 1));
                int pos = token.find(":");
                std::string tensor_name = token.substr(0, pos);
-               const std::vector<char> delimiters = {'{', ' ', ':', '\n', '\"'};
+               const std::vector<char> delimiters = { '{', ' ', ':', '\n', '\"' };
 
-               for (autodelimiter : delimiters)
+               for (auto &delimiter : delimiters)
                        tensor_name.erase(std::remove(tensor_name.begin(), tensor_name.end(), delimiter), tensor_name.end());
 
                if (tensor_name.compare((std::string("tensor") + std::to_string(idx + 1))) != 0) {
@@ -252,7 +250,9 @@ int OutputMetadata::Parse(JsonObject *root, std::string key_name)
 
                // TODO. add tensor information here.
 
-               LayerInfo layer = { name_value, };
+               LayerInfo layer = {
+                       name_value,
+               };
 
                if (json_object_has_member(tensor_object, "postprocess")) {
                        int ret = GetPostProcess(tensor_object, layer);
@@ -263,7 +263,6 @@ int OutputMetadata::Parse(JsonObject *root, std::string key_name)
                }
 
                _tensor_info.insert(std::make_pair(name_value, layer));
-
        }
 
        parsed = true;