MCPcopy Create free account
hub / github.com/OAID/Tengine / filter_boxs

Function filter_boxs

executor/operator/common/rpn.cpp:155–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155void filter_boxs(std::vector<SBox>& boxes, float* box, float* score, int min_size, int src_scale, int src_w, int src_h,
156 int feat_w, int feat_h, int num_anchors, int feat_c)
157{
158 float local_minsize = min_size * src_scale;
159 boxes.clear();
160
161 int feat_c_ = feat_c / 4;
162 int one_step = feat_h * feat_w;
163 int step = 4 * one_step;
164 int offset_w, offset_h, offset_x, offset_y, offset_s;
165
166 for(int h = 0; h < feat_h; ++h)
167 {
168 for(int w = 0; w < feat_w; ++w)
169 {
170 offset_x = h * feat_w + w;
171 offset_y = offset_x + one_step;
172 offset_w = offset_y + one_step;
173 offset_h = offset_w + one_step;
174 offset_s = one_step * num_anchors + offset_x;
175 for(int c = 0; c < feat_c_; ++c)
176 {
177 float width = box[offset_w];
178 float height = box[offset_h];
179 if((width >= local_minsize) & (height >= local_minsize))
180 {
181 SBox tmp;
182 tmp.x0 = box[offset_x] - 0.5 * width;
183 tmp.y0 = box[offset_y] - 0.5 * height;
184 tmp.x1 = box[offset_x] + 0.5 * width;
185 tmp.y1 = box[offset_y] + 0.5 * height;
186 tmp.x0 = MIN(MAX(tmp.x0, 0), src_w);
187 tmp.y0 = MIN(MAX(tmp.y0, 0), src_h);
188 tmp.x1 = MIN(MAX(tmp.x1, 0), src_w);
189 tmp.y1 = MIN(MAX(tmp.y1, 0), src_h);
190 tmp.score = score[offset_s];
191 boxes.push_back(tmp);
192 }
193 offset_x += step;
194 offset_y += step;
195 offset_w += step;
196 offset_h += step;
197 offset_s += one_step;
198 }
199 }
200 }
201}
202
203void nms_rpn(std::vector<SBox>& input_boxes, float nms_thresh)
204{

Callers 1

RunMethod · 0.85

Calls 1

clearMethod · 0.80

Tested by

no test coverage detected