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

Function nms_rpn

executor/operator/common/rpn.cpp:203–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203void nms_rpn(std::vector<SBox>& input_boxes, float nms_thresh)
204{
205 std::vector<float> vArea(input_boxes.size());
206 for(int i = 0; i < ( int )input_boxes.size(); ++i)
207 {
208 vArea[i] =
209 (input_boxes.at(i).x1 - input_boxes.at(i).x0 + 1) * (input_boxes.at(i).y1 - input_boxes.at(i).y0 + 1);
210 }
211 for(int i = 0; i < ( int )input_boxes.size(); ++i)
212 {
213 for(int j = i + 1; j < ( int )input_boxes.size();)
214 {
215 float xx1 = std::max(input_boxes[i].x0, input_boxes[j].x0);
216 float yy1 = std::max(input_boxes[i].y0, input_boxes[j].y0);
217 float xx2 = std::min(input_boxes[i].x1, input_boxes[j].x1);
218 float yy2 = std::min(input_boxes[i].y1, input_boxes[j].y1);
219 float w = std::max(float(0), xx2 - xx1 + 1);
220 float h = std::max(float(0), yy2 - yy1 + 1);
221 float inter = w * h;
222 float ovr = inter / (vArea[i] + vArea[j] - inter);
223 if(ovr >= nms_thresh)
224 {
225 input_boxes.erase(input_boxes.begin() + j);
226 vArea.erase(vArea.begin() + j);
227 }
228 else
229 {
230 j++;
231 }
232 }
233 }
234}
235namespace TEngine {
236
237namespace RPNImpl {

Callers 1

RunMethod · 0.85

Calls 4

maxFunction · 0.85
minFunction · 0.85
beginMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected