From 3a0802d70c7a6286ac1ca871efc2498550295aa5 Mon Sep 17 00:00:00 2001 From: Francesco Gatti Date: Mon, 27 Jul 2020 13:45:42 +0200 Subject: [PATCH] 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 --- src/Yolo3Detection.cpp | 47 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Yolo3Detection.cpp b/src/Yolo3Detection.cpp index c76af20..27f393f 100644 --- a/src/Yolo3Detection.cpp +++ b/src/Yolo3Detection.cpp @@ -113,34 +113,35 @@ void Yolo3Detection::postprocess(const int bi, const bool mAP){ int x1 = (b.x+b.w/2.); int y0 = (b.y-b.h/2.); int y1 = (b.y+b.h/2.); - int obj_class = -1; - float prob = 0; + for(int c=0; c= confThreshold) { - obj_class = c; - prob = dets[j].prob[c]; + int obj_class = c; + float prob = dets[j].prob[c]; + + // convert to image coords + x0 = x_ratio*x0; + x1 = x_ratio*x1; + y0 = y_ratio*y0; + y1 = y_ratio*y1; + + tk::dnn::box res; + res.cl = obj_class; + res.prob = prob; + res.x = x0; + res.y = y0; + res.w = x1 - x0; + res.h = y1 - y0; + + // FIXME: this shuld be useless + // if(mAP) + // for(int c=0; c= 0) { - // convert to image coords - x0 = x_ratio*x0; - x1 = x_ratio*x1; - y0 = y_ratio*y0; - y1 = y_ratio*y1; - - tk::dnn::box res; - res.cl = obj_class; - res.prob = prob; - res.x = x0; - res.y = y0; - res.w = x1 - x0; - res.h = y1 - y0; - if(mAP) - for(int c=0; c