Resolve detection objects pick by prob threshold.

Before this it will only pick the last object with prob > thresh wich is absolutely wrong
Now it picks all the objects with prob > thesh.

fixes #94
This commit is contained in:
Francesco Gatti
2020-07-27 13:45:42 +02:00
parent f4970d1e6f
commit 3a0802d70c
+11 -10
View File
@@ -113,16 +113,12 @@ void Yolo3Detection::postprocess(const int bi, const bool mAP){
int x1 = (b.x+b.w/2.); int x1 = (b.x+b.w/2.);
int y0 = (b.y-b.h/2.); int y0 = (b.y-b.h/2.);
int y1 = (b.y+b.h/2.); int y1 = (b.y+b.h/2.);
int obj_class = -1;
float prob = 0;
for(int c=0; c<classes; c++) { for(int c=0; c<classes; c++) {
if(dets[j].prob[c] >= confThreshold) { if(dets[j].prob[c] >= confThreshold) {
obj_class = c; int obj_class = c;
prob = dets[j].prob[c]; float prob = dets[j].prob[c];
}
}
if(obj_class >= 0) {
// convert to image coords // convert to image coords
x0 = x_ratio*x0; x0 = x_ratio*x0;
x1 = x_ratio*x1; x1 = x_ratio*x1;
@@ -136,12 +132,17 @@ void Yolo3Detection::postprocess(const int bi, const bool mAP){
res.y = y0; res.y = y0;
res.w = x1 - x0; res.w = x1 - x0;
res.h = y1 - y0; res.h = y1 - y0;
if(mAP)
for(int c=0; c<classes; c++) // FIXME: this shuld be useless
res.probs.push_back(dets[j].prob[c]); // if(mAP)
// for(int c=0; c<classes; c++)
// res.probs.push_back(dets[j].prob[c]);
detected.push_back(res); detected.push_back(res);
} }
} }
}
batchDetected.push_back(detected); batchDetected.push_back(detected);
} }