2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __DECODE_INFO_H__
18 #define __DECODE_INFO_H__
25 #include <MetadataType.h>
26 #include <mv_inference_type.h>
27 #include <opencv2/core.hpp>
45 std::vector<int> strides;
46 std::vector<float> aspectRatios;
47 bool isReduceBoxedInLowestLayer;
48 float interpolatedScaleAspectRatio;
49 bool isFixedAnchorSize;
50 bool isExponentialBoxScale;
58 inference_score_type_e type;
59 std::map<std::string, inference_score_type_e> supportedCellType;
60 std::vector<std::vector<double> > vxScales;
61 std::vector<std::vector<double> > vyScales;
65 inference_box_nms_type_e mode; /**< 0: standard */
67 std::map<std::string, inference_box_nms_type_e> supportedBoxNmsTypes;
73 cv::Point2f startPoint;
78 struct RoiOptionParam {
82 cv::Point2f centerPoint;
91 AnchorParam anchorParam;
92 std::vector<cv::Rect2f> anchorBoxes;
95 RoiOptionParam roiOptParam;
99 nmsParam.mode = INFERENCE_BOX_NMS_TYPE_NONE;
100 nmsParam.iouThreshold = 0.2f;
101 nmsParam.supportedBoxNmsTypes.insert({ "STANDARD", INFERENCE_BOX_NMS_TYPE_STANDARD });
103 rotParam.startPointIndex = -1;
104 rotParam.endPointIndex = -1;
105 rotParam.startPoint = cv::Point2f(0.f, 0.f);
106 rotParam.endPoint = cv::Point2f(0.f, 0.f);
107 rotParam.baseAngle = 0.f;
109 roiOptParam.startPointIndex = -1;
110 roiOptParam.endPointIndex = -1;
111 roiOptParam.centerPointIndex = -1;
112 roiOptParam.centerPoint = cv::Point2f(0.f, 0.f);
113 roiOptParam.shiftX = 0.f;
114 roiOptParam.shiftY = 0.f;
115 roiOptParam.scaleX = 1.f;
116 roiOptParam.scaleY = 1.f;
117 roiOptParam.mode = -1;
120 ~DecodeInfo() = default;
122 std::vector<cv::Rect2f> &GetAnchorBoxAll();
123 bool IsAnchorBoxEmpty();
124 void AddAnchorBox(cv::Rect2f &ahcnor);
125 void ClearAnchorBox();
128 int ParseAnchorParam(JsonObject *root);
129 int GenerateAnchor();
130 bool IsFixedAnchorSize();
131 bool IsExponentialBoxScale();
132 float GetAnchorXscale();
133 float GetAnchorYscale();
134 float GetAnchorWscale();
135 float GetAnchorHscale();
136 float CalculateScale(float min, float max, int index, int maxStride);
139 int ParseNms(JsonObject *root);
141 float GetNmsIouThreshold();
144 int ParseRotate(JsonObject *root);
145 int GetRotStartPointIndex();
146 int GetRotEndPointIndex();
147 float GetBaseAngle();
150 int ParseRoiOption(JsonObject *root);
152 int GetRoiCenterPointIndex();
153 int GetRoiStartPointIndex();
154 int GetRoiEndPointIndex();