MCPcopy Create free account
hub / github.com/amov-lab/Prometheus / correct_boxes

Function correct_boxes

Modules/object_detection/src/darknet_lib/src/data.c:179–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void correct_boxes(box_label *boxes, int n, float dx, float dy, float sx, float sy, int flip)
180{
181 int i;
182 for(i = 0; i < n; ++i){
183 if(boxes[i].x == 0 && boxes[i].y == 0) {
184 boxes[i].x = 999999;
185 boxes[i].y = 999999;
186 boxes[i].w = 999999;
187 boxes[i].h = 999999;
188 continue;
189 }
190 boxes[i].left = boxes[i].left * sx - dx;
191 boxes[i].right = boxes[i].right * sx - dx;
192 boxes[i].top = boxes[i].top * sy - dy;
193 boxes[i].bottom = boxes[i].bottom* sy - dy;
194
195 if(flip){
196 float swap = boxes[i].left;
197 boxes[i].left = 1. - boxes[i].right;
198 boxes[i].right = 1. - swap;
199 }
200
201 boxes[i].left = constrain(0, 1, boxes[i].left);
202 boxes[i].right = constrain(0, 1, boxes[i].right);
203 boxes[i].top = constrain(0, 1, boxes[i].top);
204 boxes[i].bottom = constrain(0, 1, boxes[i].bottom);
205
206 boxes[i].x = (boxes[i].left+boxes[i].right)/2;
207 boxes[i].y = (boxes[i].top+boxes[i].bottom)/2;
208 boxes[i].w = (boxes[i].right - boxes[i].left);
209 boxes[i].h = (boxes[i].bottom - boxes[i].top);
210
211 boxes[i].w = constrain(0, 1, boxes[i].w);
212 boxes[i].h = constrain(0, 1, boxes[i].h);
213 }
214}
215
216void fill_truth_swag(char *path, float *truth, int classes, int flip, float dx, float dy, float sx, float sy)
217{

Callers 3

fill_truth_swagFunction · 0.85
fill_truth_regionFunction · 0.85
fill_truth_detectionFunction · 0.85

Calls 1

constrainFunction · 0.85

Tested by

no test coverage detected