Refactoring Metadata 64/280864/3
authorKwanghoon Son <k.son@samsung.com>
Tue, 6 Sep 2022 05:41:02 +0000 (01:41 -0400)
committerkwang son <k.son@samsung.com>
Wed, 7 Sep 2022 05:10:55 +0000 (05:10 +0000)
[Issue type] refactoring

- split long header implementation
- class initialization
- remove unused function

Change-Id: I049c3ebdf64980e9737d66e8afc122bc1b6cc395
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
mv_machine_learning/inference/include/Metadata.h
mv_machine_learning/inference/include/OutputMetadata.h
mv_machine_learning/inference/src/DecodeInfo.cpp [new file with mode: 0644]
mv_machine_learning/inference/src/OutputMetadata.cpp

index 6ff9c39..b12fc75 100644 (file)
@@ -74,10 +74,6 @@ public:
        OutputMetadata &GetOutputMeta();
 
 private:
-       int ParseInputMeta(JsonObject *object);
-       int ParseOutputMeta(JsonObject *object);
-
-private:
        std::string mMetafile;
 
        InputMetadata mInputMeta;
index a19ef59..72f51fe 100644 (file)
@@ -49,12 +49,15 @@ namespace inference
 class OutputMetadata
 {
 private:
-       bool parsed;
+       bool parsed = false;
        ScoreInfo score;
        box::BoxInfo box;
        Landmark landmark;
        OffsetVec offsetVec;
-       std::map<std::string, inference_tensor_shape_type_e> mSupportedShapeType;
+       std::map<std::string, inference_tensor_shape_type_e> mSupportedShapeType = {
+               { "NCHW", INFERENCE_TENSOR_SHAPE_NCHW },
+               { "NHWC", INFERENCE_TENSOR_SHAPE_NHWC }
+       };
 
        int ParseScore(JsonObject *root);
        int ParseBox(JsonObject *root);
@@ -63,13 +66,6 @@ private:
 
 public:
        /**
-                * @brief   Creates an OutputMetadata class instance.
-                *
-                * @since_tizen 6.5
-                */
-       OutputMetadata();
-
-       /**
                 * @brief   Destroys an OutputMetadata class instance including
                 *          its all resources.
                 *
diff --git a/mv_machine_learning/inference/src/DecodeInfo.cpp b/mv_machine_learning/inference/src/DecodeInfo.cpp
new file mode 100644 (file)
index 0000000..fd5ed84
--- /dev/null
@@ -0,0 +1,365 @@
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <DecodeInfo.h>
+
+using namespace mediavision::inference;
+using namespace mediavision::inference::box;
+
+void DecodeInfo::AddAnchorBox(cv::Rect2f &anchor)
+{
+       anchorBoxes.push_back(anchor);
+}
+
+void DecodeInfo::ClearAnchorBox()
+{
+       anchorBoxes.clear();
+}
+
+std::vector<cv::Rect2f> &DecodeInfo::GetAnchorBoxAll()
+{
+       return anchorBoxes;
+}
+
+bool DecodeInfo::IsAnchorBoxEmpty()
+{
+       return anchorBoxes.empty();
+}
+
+int DecodeInfo::ParseAnchorParam(JsonObject *root)
+{
+       JsonObject *object = json_object_get_object_member(root, "anchor");
+
+       anchorParam.mode = static_cast<int>(json_object_get_int_member(object, "mode"));
+
+       anchorParam.numLayers = static_cast<int>(json_object_get_int_member(object, "num_layers"));
+       anchorParam.minScale = static_cast<float>(json_object_get_double_member(object, "min_scale"));
+       anchorParam.maxScale = static_cast<float>(json_object_get_double_member(object, "max_scale"));
+       anchorParam.inputSizeHeight = static_cast<int>(json_object_get_int_member(object, "input_size_height"));
+       anchorParam.inputSizeWidth = static_cast<int>(json_object_get_int_member(object, "input_size_width"));
+       anchorParam.anchorOffsetX = static_cast<float>(json_object_get_double_member(object, "anchor_offset_x"));
+       anchorParam.anchorOffsetY = static_cast<float>(json_object_get_double_member(object, "anchor_offset_y"));
+       anchorParam.isReduceBoxedInLowestLayer =
+                       static_cast<bool>(json_object_get_boolean_member(object, "reduce_boxed_in_lowest_layer"));
+       anchorParam.interpolatedScaleAspectRatio =
+                       static_cast<float>(json_object_get_double_member(object, "interpolated_scale_aspect_ratio"));
+       anchorParam.isFixedAnchorSize = static_cast<bool>(json_object_get_boolean_member(object, "fixed_anchor_size"));
+       anchorParam.isExponentialBoxScale =
+                       static_cast<bool>(json_object_get_boolean_member(object, "exponential_box_scale"));
+
+       anchorParam.xScale = static_cast<float>(json_object_get_double_member(object, "x_scale"));
+       anchorParam.yScale = static_cast<float>(json_object_get_double_member(object, "y_scale"));
+       anchorParam.wScale = static_cast<float>(json_object_get_double_member(object, "w_scale"));
+       anchorParam.hScale = static_cast<float>(json_object_get_double_member(object, "h_scale"));
+
+       JsonArray *array = json_object_get_array_member(object, "strides");
+       unsigned int elements2 = json_array_get_length(array);
+       for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) {
+               auto stride = static_cast<int>(json_array_get_int_element(array, elem2));
+               anchorParam.strides.push_back(stride);
+               LOGI("stride: %d", stride);
+       }
+
+       array = json_object_get_array_member(object, "aspect_ratios");
+       elements2 = json_array_get_length(array);
+       for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) {
+               auto aspectRatio = static_cast<float>(json_array_get_double_element(array, elem2));
+               anchorParam.aspectRatios.push_back(aspectRatio);
+               LOGI("aspectRatio: %.4f", aspectRatio);
+       }
+
+       return MEDIA_VISION_ERROR_NONE;
+}
+
+int DecodeInfo::ParseCellParam(JsonObject *root)
+{
+       JsonObject *object = json_object_get_object_member(root, "cell");
+
+       cellParam.numScales = static_cast<int>(json_object_get_int_member(object, "num_scales"));
+
+       JsonArray *array = json_object_get_array_member(object, "scales");
+       unsigned int elements2 = json_array_get_length(array);
+       for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) {
+               auto scale = static_cast<int>(json_array_get_int_element(array, elem2));
+               cellParam.scales.push_back(scale);
+               LOGI("scale: %d", scale);
+       }
+
+       cellParam.offsetScales = static_cast<int>(json_object_get_int_member(object, "offset_scales"));
+       try {
+               cellParam.type = GetSupportedType(object, "type", cellParam.supportedCellType);
+       } catch (const std::exception &e) {
+               LOGE("Invalid %s", e.what());
+               return MEDIA_VISION_ERROR_INVALID_OPERATION;
+       }
+
+       return MEDIA_VISION_ERROR_NONE;
+}
+
+std::vector<int> &DecodeInfo::GetCellScalesAll()
+{
+       return cellParam.scales;
+}
+
+int DecodeInfo::GetCellNumScales()
+{
+       return cellParam.numScales;
+}
+
+int DecodeInfo::GetCellOffsetScales()
+{
+       return cellParam.offsetScales;
+}
+
+inference_score_type_e DecodeInfo::GetCellType()
+{
+       return cellParam.type;
+}
+
+float DecodeInfo::CalculateScale(float min, float max, int index, int maxStride)
+{
+       return min + (max - min) * 1.0 * index / (maxStride - 1.0f);
+}
+
+bool DecodeInfo::IsFixedAnchorSize()
+{
+       return anchorParam.isFixedAnchorSize;
+}
+
+bool DecodeInfo::IsExponentialBoxScale()
+{
+       return anchorParam.isExponentialBoxScale;
+}
+
+float DecodeInfo::GetAnchorXscale()
+{
+       return anchorParam.xScale;
+}
+
+float DecodeInfo::GetAnchorYscale()
+{
+       return anchorParam.yScale;
+}
+
+float DecodeInfo::GetAnchorWscale()
+{
+       return anchorParam.wScale;
+}
+
+float DecodeInfo::GetAnchorHscale()
+{
+       return anchorParam.hScale;
+}
+
+int DecodeInfo::GenerateAnchor()
+{
+       if (anchorParam.strides.empty() || anchorParam.aspectRatios.empty()) {
+               LOGE("Invalid anchor parameters");
+               return MEDIA_VISION_ERROR_INVALID_OPERATION;
+       }
+
+       int layerId = 0;
+       ClearAnchorBox();
+       while (layerId < anchorParam.numLayers) {
+               std::vector<float> anchorHeight;
+               std::vector<float> anchorWidth;
+               std::vector<float> aspectRatios;
+               std::vector<float> scales;
+
+               int lastSameStrideLayer = layerId;
+               std::vector<float>::iterator iter1, iter2;
+               while ((lastSameStrideLayer < anchorParam.numLayers) &&
+                          (anchorParam.strides[lastSameStrideLayer] == anchorParam.strides[layerId])) {
+                       const float scale = CalculateScale(anchorParam.minScale, anchorParam.maxScale, lastSameStrideLayer,
+                                                                                          anchorParam.strides.size());
+
+                       if (lastSameStrideLayer == 0 && anchorParam.isReduceBoxedInLowestLayer) {
+                               aspectRatios.push_back(1.0);
+                               aspectRatios.push_back(2.0);
+                               aspectRatios.push_back(0.5);
+                               scales.push_back(0.1);
+                               scales.push_back(scale);
+                               scales.push_back(scale);
+                       } else {
+                               for (iter1 = anchorParam.aspectRatios.begin(); iter1 != anchorParam.aspectRatios.end(); ++iter1) {
+                                       aspectRatios.push_back((*iter1));
+                                       scales.push_back(scale);
+                               }
+                               if (anchorParam.interpolatedScaleAspectRatio > 0.0f) {
+                                       const float scaleNext = lastSameStrideLayer == static_cast<int>(anchorParam.strides.size()) - 1 ?
+                                                                                                       1.0f :
+                                                                                                       CalculateScale(anchorParam.minScale, anchorParam.maxScale,
+                                                                                                                                  lastSameStrideLayer + 1, anchorParam.strides.size());
+                                       scales.push_back(std::sqrt(scale * scaleNext));
+                                       aspectRatios.push_back(anchorParam.interpolatedScaleAspectRatio);
+                               }
+                       }
+                       lastSameStrideLayer++;
+               }
+
+               for (iter1 = aspectRatios.begin(), iter2 = scales.begin();
+                        (iter1 != aspectRatios.end() && iter2 != scales.end()); ++iter1, ++iter2) {
+                       const float ratioSqrts = std::sqrt((*iter1));
+                       anchorHeight.push_back((*iter2) / ratioSqrts);
+                       anchorWidth.push_back((*iter2) * ratioSqrts);
+               }
+
+               const int stride = anchorParam.strides[layerId];
+               int featureMapHeight = std::ceil(1.0f * anchorParam.inputSizeHeight / stride);
+               int featureMapWidth = std::ceil(1.0f * anchorParam.inputSizeWidth / stride);
+
+               for (int y = 0; y < featureMapHeight; ++y) {
+                       for (int x = 0; x < featureMapWidth; ++x) {
+                               for (int anchorId = 0; anchorId < (int) anchorHeight.size(); ++anchorId) {
+                                       cv::Rect2f anchor = { cv::Point2f { (x + anchorParam.anchorOffsetX) * 1.0f / featureMapWidth,
+                                                                                                               (y + anchorParam.anchorOffsetY) * 1.0f / featureMapHeight },
+                                                                                 anchorParam.isFixedAnchorSize ?
+                                                                                                 cv::Size2f { 1.0f, 1.0f } :
+                                                                                                 cv::Size2f { anchorWidth[anchorId], anchorWidth[anchorId] } };
+                                       AddAnchorBox(anchor);
+                               }
+                       }
+               }
+               layerId = lastSameStrideLayer;
+       }
+
+       if (IsAnchorBoxEmpty()) {
+               LOGE("Anchor boxes are empty");
+               return MEDIA_VISION_ERROR_INVALID_OPERATION;
+       }
+
+       return MEDIA_VISION_ERROR_NONE;
+}
+
+int DecodeInfo::ParseNms(JsonObject *root)
+{
+       if (!json_object_has_member(root, "nms")) {
+               LOGI("nms is empty. skip it");
+               return MEDIA_VISION_ERROR_NONE;
+       }
+
+       JsonObject *object = json_object_get_object_member(root, "nms");
+       try {
+               nmsParam.mode = GetSupportedType(object, "mode", nmsParam.supportedBoxNmsTypes);
+       } catch (const std::exception &e) {
+               LOGE("Invalid %s", e.what());
+               return MEDIA_VISION_ERROR_INVALID_OPERATION;
+       }
+
+       nmsParam.iouThreshold = static_cast<float>(json_object_get_double_member(object, "iou_threshold"));
+
+       return MEDIA_VISION_ERROR_NONE;
+}
+
+int DecodeInfo::GetNmsMode()
+{
+       return nmsParam.mode;
+}
+
+float DecodeInfo::GetNmsIouThreshold()
+{
+       return nmsParam.iouThreshold;
+}
+
+int DecodeInfo::ParseRotate(JsonObject *root)
+{
+       if (!json_object_has_member(root, "rotate")) {
+               LOGI("rotate is empty. skip it");
+               return MEDIA_VISION_ERROR_NONE;
+       }
+
+       JsonObject *object = json_object_get_object_member(root, "rotate");
+       rotParam.baseAngle = static_cast<float>(json_object_get_double_member(object, "base_angle"));
+       rotParam.startPointIndex = static_cast<int>(json_object_get_int_member(object, "start_point_index"));
+       rotParam.endPointIndex = static_cast<int>(json_object_get_int_member(object, "end_point_index"));
+
+       return MEDIA_VISION_ERROR_NONE;
+}
+
+int DecodeInfo::GetRotStartPointIndex()
+{
+       return rotParam.startPointIndex;
+}
+
+int DecodeInfo::GetRotEndPointIndex()
+{
+       return rotParam.endPointIndex;
+}
+
+float DecodeInfo::GetBaseAngle()
+{
+       return rotParam.baseAngle;
+}
+
+int DecodeInfo::GetRoiMode()
+{
+       return roiOptParam.mode;
+}
+
+int DecodeInfo::GetRoiStartPointIndex()
+{
+       return roiOptParam.startPointIndex;
+}
+
+int DecodeInfo::GetRoiEndPointIndex()
+{
+       return roiOptParam.endPointIndex;
+}
+
+int DecodeInfo::GetRoiCenterPointIndex()
+{
+       return roiOptParam.centerPointIndex;
+}
+
+float DecodeInfo::GetShiftX()
+{
+       return roiOptParam.shiftX;
+}
+
+float DecodeInfo::GetShiftY()
+{
+       return roiOptParam.shiftY;
+}
+
+float DecodeInfo::GetScaleX()
+{
+       return roiOptParam.scaleX;
+}
+
+float DecodeInfo::GetScaleY()
+{
+       return roiOptParam.scaleY;
+}
+
+int DecodeInfo::ParseRoiOption(JsonObject *root)
+{
+       if (!json_object_has_member(root, "roi")) {
+               LOGI("roi is empty. skip it");
+               return MEDIA_VISION_ERROR_NONE;
+       }
+
+       JsonObject *object = json_object_get_object_member(root, "roi");
+       roiOptParam.startPointIndex = static_cast<int>(json_object_get_int_member(object, "start_point_index"));
+       roiOptParam.endPointIndex = static_cast<int>(json_object_get_int_member(object, "end_point_index"));
+       roiOptParam.centerPointIndex = static_cast<int>(json_object_get_int_member(object, "center_point_index"));
+       roiOptParam.shiftX = static_cast<float>(json_object_get_double_member(object, "shift_x"));
+       roiOptParam.shiftY = static_cast<float>(json_object_get_double_member(object, "shift_y"));
+       roiOptParam.scaleX = static_cast<float>(json_object_get_double_member(object, "scale_x"));
+       roiOptParam.scaleY = static_cast<float>(json_object_get_double_member(object, "scale_y"));
+       roiOptParam.mode = static_cast<int>(json_object_get_int_member(object, "scale_mode"));
+
+       return MEDIA_VISION_ERROR_NONE;
+}
index 2fb49e2..bdcbce4 100644 (file)
@@ -31,13 +31,6 @@ namespace mediavision
 {
 namespace inference
 {
-OutputMetadata::OutputMetadata() : parsed(false), score(), box(), landmark(), offsetVec()
-{
-       // shape_type
-       mSupportedShapeType.insert({ "NCHW", INFERENCE_TENSOR_SHAPE_NCHW });
-       mSupportedShapeType.insert({ "NHWC", INFERENCE_TENSOR_SHAPE_NHWC });
-}
-
 int OutputMetadata::ParseScore(JsonObject *root)
 {
        if (!json_object_has_member(root, "score")) {
@@ -48,26 +41,6 @@ int OutputMetadata::ParseScore(JsonObject *root)
        return score.ParseScore(root);
 }
 
-void DecodeInfo::AddAnchorBox(cv::Rect2f &anchor)
-{
-       anchorBoxes.push_back(anchor);
-}
-
-void DecodeInfo::ClearAnchorBox()
-{
-       anchorBoxes.clear();
-}
-
-std::vector<cv::Rect2f> &DecodeInfo::GetAnchorBoxAll()
-{
-       return anchorBoxes;
-}
-
-bool DecodeInfo::IsAnchorBoxEmpty()
-{
-       return anchorBoxes.empty();
-}
-
 int OutputMetadata::ParseBox(JsonObject *root)
 {
        if (!json_object_has_member(root, "box")) {
@@ -78,332 +51,6 @@ int OutputMetadata::ParseBox(JsonObject *root)
        return box.ParseBox(root);
 }
 
-int DecodeInfo::ParseAnchorParam(JsonObject *root)
-{
-       JsonObject *object = json_object_get_object_member(root, "anchor");
-
-       anchorParam.mode = static_cast<int>(json_object_get_int_member(object, "mode"));
-
-       anchorParam.numLayers = static_cast<int>(json_object_get_int_member(object, "num_layers"));
-       anchorParam.minScale = static_cast<float>(json_object_get_double_member(object, "min_scale"));
-       anchorParam.maxScale = static_cast<float>(json_object_get_double_member(object, "max_scale"));
-       anchorParam.inputSizeHeight = static_cast<int>(json_object_get_int_member(object, "input_size_height"));
-       anchorParam.inputSizeWidth = static_cast<int>(json_object_get_int_member(object, "input_size_width"));
-       anchorParam.anchorOffsetX = static_cast<float>(json_object_get_double_member(object, "anchor_offset_x"));
-       anchorParam.anchorOffsetY = static_cast<float>(json_object_get_double_member(object, "anchor_offset_y"));
-       anchorParam.isReduceBoxedInLowestLayer =
-                       static_cast<bool>(json_object_get_boolean_member(object, "reduce_boxed_in_lowest_layer"));
-       anchorParam.interpolatedScaleAspectRatio =
-                       static_cast<float>(json_object_get_double_member(object, "interpolated_scale_aspect_ratio"));
-       anchorParam.isFixedAnchorSize = static_cast<bool>(json_object_get_boolean_member(object, "fixed_anchor_size"));
-       anchorParam.isExponentialBoxScale =
-                       static_cast<bool>(json_object_get_boolean_member(object, "exponential_box_scale"));
-
-       anchorParam.xScale = static_cast<float>(json_object_get_double_member(object, "x_scale"));
-       anchorParam.yScale = static_cast<float>(json_object_get_double_member(object, "y_scale"));
-       anchorParam.wScale = static_cast<float>(json_object_get_double_member(object, "w_scale"));
-       anchorParam.hScale = static_cast<float>(json_object_get_double_member(object, "h_scale"));
-
-       JsonArray *array = json_object_get_array_member(object, "strides");
-       unsigned int elements2 = json_array_get_length(array);
-       for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) {
-               auto stride = static_cast<int>(json_array_get_int_element(array, elem2));
-               anchorParam.strides.push_back(stride);
-               LOGI("stride: %d", stride);
-       }
-
-       array = json_object_get_array_member(object, "aspect_ratios");
-       elements2 = json_array_get_length(array);
-       for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) {
-               auto aspectRatio = static_cast<float>(json_array_get_double_element(array, elem2));
-               anchorParam.aspectRatios.push_back(aspectRatio);
-               LOGI("aspectRatio: %.4f", aspectRatio);
-       }
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int DecodeInfo::ParseCellParam(JsonObject *root)
-{
-       JsonObject *object = json_object_get_object_member(root, "cell");
-
-       cellParam.numScales = static_cast<int>(json_object_get_int_member(object, "num_scales"));
-
-       JsonArray *array = json_object_get_array_member(object, "scales");
-       unsigned int elements2 = json_array_get_length(array);
-       for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) {
-               auto scale = static_cast<int>(json_array_get_int_element(array, elem2));
-               cellParam.scales.push_back(scale);
-               LOGI("scale: %d", scale);
-       }
-
-       cellParam.offsetScales = static_cast<int>(json_object_get_int_member(object, "offset_scales"));
-       try {
-               cellParam.type = GetSupportedType(object, "type", cellParam.supportedCellType);
-       } catch (const std::exception &e) {
-               LOGE("Invalid %s", e.what());
-               return MEDIA_VISION_ERROR_INVALID_OPERATION;
-       }
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-std::vector<int> &DecodeInfo::GetCellScalesAll()
-{
-       return cellParam.scales;
-}
-
-int DecodeInfo::GetCellNumScales()
-{
-       return cellParam.numScales;
-}
-
-int DecodeInfo::GetCellOffsetScales()
-{
-       return cellParam.offsetScales;
-}
-
-inference_score_type_e DecodeInfo::GetCellType()
-{
-       return cellParam.type;
-}
-
-float DecodeInfo::CalculateScale(float min, float max, int index, int maxStride)
-{
-       return min + (max - min) * 1.0 * index / (maxStride - 1.0f);
-}
-
-bool DecodeInfo::IsFixedAnchorSize()
-{
-       return anchorParam.isFixedAnchorSize;
-       ;
-}
-
-bool DecodeInfo::IsExponentialBoxScale()
-{
-       return anchorParam.isExponentialBoxScale;
-}
-
-float DecodeInfo::GetAnchorXscale()
-{
-       return anchorParam.xScale;
-}
-
-float DecodeInfo::GetAnchorYscale()
-{
-       return anchorParam.yScale;
-}
-
-float DecodeInfo::GetAnchorWscale()
-{
-       return anchorParam.wScale;
-}
-
-float DecodeInfo::GetAnchorHscale()
-{
-       return anchorParam.hScale;
-}
-
-int DecodeInfo::GenerateAnchor()
-{
-       if (anchorParam.strides.empty() || anchorParam.aspectRatios.empty()) {
-               LOGE("Invalid anchor parameters");
-               return MEDIA_VISION_ERROR_INVALID_OPERATION;
-       }
-
-       int layerId = 0;
-       ClearAnchorBox();
-       while (layerId < anchorParam.numLayers) {
-               std::vector<float> anchorHeight;
-               std::vector<float> anchorWidth;
-               std::vector<float> aspectRatios;
-               std::vector<float> scales;
-
-               int lastSameStrideLayer = layerId;
-               std::vector<float>::iterator iter1, iter2;
-               while ((lastSameStrideLayer < anchorParam.numLayers) &&
-                          (anchorParam.strides[lastSameStrideLayer] == anchorParam.strides[layerId])) {
-                       const float scale = CalculateScale(anchorParam.minScale, anchorParam.maxScale, lastSameStrideLayer,
-                                                                                          anchorParam.strides.size());
-
-                       if (lastSameStrideLayer == 0 && anchorParam.isReduceBoxedInLowestLayer) {
-                               aspectRatios.push_back(1.0);
-                               aspectRatios.push_back(2.0);
-                               aspectRatios.push_back(0.5);
-                               scales.push_back(0.1);
-                               scales.push_back(scale);
-                               scales.push_back(scale);
-                       } else {
-                               for (iter1 = anchorParam.aspectRatios.begin(); iter1 != anchorParam.aspectRatios.end(); ++iter1) {
-                                       aspectRatios.push_back((*iter1));
-                                       scales.push_back(scale);
-                               }
-                               if (anchorParam.interpolatedScaleAspectRatio > 0.0f) {
-                                       const float scaleNext = lastSameStrideLayer == static_cast<int>(anchorParam.strides.size()) - 1 ?
-                                                                                                       1.0f :
-                                                                                                       CalculateScale(anchorParam.minScale, anchorParam.maxScale,
-                                                                                                                                  lastSameStrideLayer + 1, anchorParam.strides.size());
-                                       scales.push_back(std::sqrt(scale * scaleNext));
-                                       aspectRatios.push_back(anchorParam.interpolatedScaleAspectRatio);
-                               }
-                       }
-                       lastSameStrideLayer++;
-               }
-
-               for (iter1 = aspectRatios.begin(), iter2 = scales.begin();
-                        (iter1 != aspectRatios.end() && iter2 != scales.end()); ++iter1, ++iter2) {
-                       const float ratioSqrts = std::sqrt((*iter1));
-                       anchorHeight.push_back((*iter2) / ratioSqrts);
-                       anchorWidth.push_back((*iter2) * ratioSqrts);
-               }
-
-               const int stride = anchorParam.strides[layerId];
-               int featureMapHeight = std::ceil(1.0f * anchorParam.inputSizeHeight / stride);
-               int featureMapWidth = std::ceil(1.0f * anchorParam.inputSizeWidth / stride);
-
-               for (int y = 0; y < featureMapHeight; ++y) {
-                       for (int x = 0; x < featureMapWidth; ++x) {
-                               for (int anchorId = 0; anchorId < (int) anchorHeight.size(); ++anchorId) {
-                                       cv::Rect2f anchor = { cv::Point2f { (x + anchorParam.anchorOffsetX) * 1.0f / featureMapWidth,
-                                                                                                               (y + anchorParam.anchorOffsetY) * 1.0f / featureMapHeight },
-                                                                                 anchorParam.isFixedAnchorSize ?
-                                                                                                 cv::Size2f { 1.0f, 1.0f } :
-                                                                                                 cv::Size2f { anchorWidth[anchorId], anchorWidth[anchorId] } };
-                                       AddAnchorBox(anchor);
-                               }
-                       }
-               }
-               layerId = lastSameStrideLayer;
-       }
-
-       if (IsAnchorBoxEmpty()) {
-               LOGE("Anchor boxes are empty");
-               return MEDIA_VISION_ERROR_INVALID_OPERATION;
-       }
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int DecodeInfo::ParseNms(JsonObject *root)
-{
-       if (!json_object_has_member(root, "nms")) {
-               LOGI("nms is empty. skip it");
-               return MEDIA_VISION_ERROR_NONE;
-       }
-
-       JsonObject *object = json_object_get_object_member(root, "nms");
-       try {
-               nmsParam.mode = GetSupportedType(object, "mode", nmsParam.supportedBoxNmsTypes);
-       } catch (const std::exception &e) {
-               LOGE("Invalid %s", e.what());
-               return MEDIA_VISION_ERROR_INVALID_OPERATION;
-       }
-
-       nmsParam.iouThreshold = static_cast<float>(json_object_get_double_member(object, "iou_threshold"));
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int DecodeInfo::GetNmsMode()
-{
-       return nmsParam.mode;
-}
-
-float DecodeInfo::GetNmsIouThreshold()
-{
-       return nmsParam.iouThreshold;
-}
-
-int DecodeInfo::ParseRotate(JsonObject *root)
-{
-       if (!json_object_has_member(root, "rotate")) {
-               LOGI("rotate is empty. skip it");
-               return MEDIA_VISION_ERROR_NONE;
-       }
-
-       JsonObject *object = json_object_get_object_member(root, "rotate");
-       rotParam.baseAngle = static_cast<float>(json_object_get_double_member(object, "base_angle"));
-       rotParam.startPointIndex = static_cast<int>(json_object_get_int_member(object, "start_point_index"));
-       rotParam.endPointIndex = static_cast<int>(json_object_get_int_member(object, "end_point_index"));
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int DecodeInfo::GetRotStartPointIndex()
-{
-       return rotParam.startPointIndex;
-}
-
-int DecodeInfo::GetRotEndPointIndex()
-{
-       return rotParam.endPointIndex;
-}
-
-float DecodeInfo::GetBaseAngle()
-{
-       return rotParam.baseAngle;
-}
-
-int DecodeInfo::GetRoiMode()
-{
-       return roiOptParam.mode;
-}
-
-int DecodeInfo::GetRoiStartPointIndex()
-{
-       return roiOptParam.startPointIndex;
-}
-
-int DecodeInfo::GetRoiEndPointIndex()
-{
-       return roiOptParam.endPointIndex;
-}
-
-int DecodeInfo::GetRoiCenterPointIndex()
-{
-       return roiOptParam.centerPointIndex;
-}
-
-float DecodeInfo::GetShiftX()
-{
-       return roiOptParam.shiftX;
-}
-
-float DecodeInfo::GetShiftY()
-{
-       return roiOptParam.shiftY;
-}
-
-float DecodeInfo::GetScaleX()
-{
-       return roiOptParam.scaleX;
-}
-
-float DecodeInfo::GetScaleY()
-{
-       return roiOptParam.scaleY;
-}
-
-int DecodeInfo::ParseRoiOption(JsonObject *root)
-{
-       if (!json_object_has_member(root, "roi")) {
-               LOGI("roi is empty. skip it");
-               return MEDIA_VISION_ERROR_NONE;
-       }
-
-       JsonObject *object = json_object_get_object_member(root, "roi");
-       roiOptParam.startPointIndex = static_cast<int>(json_object_get_int_member(object, "start_point_index"));
-       roiOptParam.endPointIndex = static_cast<int>(json_object_get_int_member(object, "end_point_index"));
-       roiOptParam.centerPointIndex = static_cast<int>(json_object_get_int_member(object, "center_point_index"));
-       roiOptParam.shiftX = static_cast<float>(json_object_get_double_member(object, "shift_x"));
-       roiOptParam.shiftY = static_cast<float>(json_object_get_double_member(object, "shift_y"));
-       roiOptParam.scaleX = static_cast<float>(json_object_get_double_member(object, "scale_x"));
-       roiOptParam.scaleY = static_cast<float>(json_object_get_double_member(object, "scale_y"));
-       roiOptParam.mode = static_cast<int>(json_object_get_int_member(object, "scale_mode"));
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 int OutputMetadata::ParseLandmark(JsonObject *root)
 {
        LOGI("ENTER");