Threshold For confidance for score of RCNN Detector
10 views (last 30 days)
Roshni Garnayak on 11 Sep 2019
Yes, it is possible to display only those bounding boxes which are above a certain threshold score. Refer to the following example of R-CNN Stop Sign Detector:
The following statement computes the bounding boxes along with their corresponding scores:
[bbox, score, label] = detect(rcnn, img, 'MiniBatchSize', 32);
“bboxes” is an M-by-4 array where each row of “bboxes” contains a four-element vector, [x,y,width,height], that specifies the upper–left corner and size of a bounding box in pixels. To draw the actual bounding boxes you need to call the “bbox” function.
You can refer to the following piece of code from the example to set a threshold for the scores:
[score, idx] = max(score);
bbox = bbox(idx, :);
annotation = sprintf('%s: (Confidence = %f)', label(idx), score);
detectedImg = insertObjectAnnotation(img, 'rectangle', bbox, annotation);
Instead of using “max” function, you can create your logic to collect the indexes of only the bounding boxes above a certain threshold score and then pass those indexes as argument to “bbox” function.