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<double> vxScales;
61 std::vector<double> vyScales;
62 unsigned int totalAnchors;
66 inference_box_nms_type_e mode; /**< 0: standard */
68 std::map<std::string, inference_box_nms_type_e> supportedBoxNmsTypes;
74 cv::Point2f startPoint;
79 struct RoiOptionParam {
83 cv::Point2f centerPoint;
92 AnchorParam anchorParam;
93 std::vector<cv::Rect2f> anchorBoxes;
94 std::vector<std::vector<cv::Rect2f> > vAnchorBoxes; // (stride) * (H * W * B) * (rect)
97 RoiOptionParam roiOptParam;
101 nmsParam.mode = INFERENCE_BOX_NMS_TYPE_NONE;
102 nmsParam.iouThreshold = 0.2f;
103 nmsParam.supportedBoxNmsTypes.insert({ "STANDARD", INFERENCE_BOX_NMS_TYPE_STANDARD });
105 rotParam.startPointIndex = -1;
106 rotParam.endPointIndex = -1;
107 rotParam.startPoint = cv::Point2f(0.f, 0.f);
108 rotParam.endPoint = cv::Point2f(0.f, 0.f);
109 rotParam.baseAngle = 0.f;
111 roiOptParam.startPointIndex = -1;
112 roiOptParam.endPointIndex = -1;
113 roiOptParam.centerPointIndex = -1;
114 roiOptParam.centerPoint = cv::Point2f(0.f, 0.f);
115 roiOptParam.shiftX = 0.f;
116 roiOptParam.shiftY = 0.f;
117 roiOptParam.scaleX = 1.f;
118 roiOptParam.scaleY = 1.f;
119 roiOptParam.mode = -1;
122 ~DecodeInfo() = default;
124 std::vector<cv::Rect2f> &GetAnchorBoxAll();
125 bool IsAnchorBoxEmpty();
126 void AddAnchorBox(cv::Rect2f &ahcnor);
127 void ClearAnchorBox();
130 int ParseAnchorParam(JsonObject *root);
131 int GenerateAnchor();
132 int GenerateYOLOAnchor();
133 bool IsFixedAnchorSize();
134 bool IsExponentialBoxScale();
135 float GetAnchorXscale();
136 float GetAnchorYscale();
137 float GetAnchorWscale();
138 float GetAnchorHscale();
139 float CalculateScale(float min, float max, int index, int maxStride);
142 int ParseNms(JsonObject *root);
144 float GetNmsIouThreshold();
147 int ParseRotate(JsonObject *root);
148 int GetRotStartPointIndex();
149 int GetRotEndPointIndex();
150 float GetBaseAngle();
153 int ParseRoiOption(JsonObject *root);
155 int GetRoiCenterPointIndex();
156 int GetRoiStartPointIndex();
157 int GetRoiEndPointIndex();