Non-Maximum-Suppression - with OpenCV cascade classifier. Uses Intersection Over Union to filter potential detections.
A simple implementation of the Non-Maximum-Suppression algorithm (NMS), using OpenCV cascade classifier. Since the OpenCV cascade does not provide the detection confidence nor probability, the bounding box proposal is made on the rate of the intersection over the union (IOU) of the detected boxes. As input the following article was uesed [1], all credits for the concept does there.
Green - all detections, red - filtered results. For more customization see the next sections.
If you don’t have a custom cascade classifier trained for your purposes, you can create one, see details [2].
For testing purposes a detector is provided, which is trained to detect toy quadcopters:
/data/cascade.xml
usage: test_cascade_nms.py [-h] [-cam CAM] [-n N] [-s S] [-iou IOU] [-so SO]
[-rev REV]
Cascade tester. Defaults: -cam 0 -n 0 -s 1.1 -iou 0.1
optional arguments:
-h, --help show this help message and exit
-cam CAM Camera ID
-n N Number of neighbors for detections
-s S Scale factor
-iou IOU Intersection Over Union threshold
-so SO Sort the detection based on their area, bigest the last
-rev REV Sort the detection based on their area, smallest the last
Playing with the cascade classifier parameters, detection rates can be improved i.e. by setting a lower value for the classifier’s neighbor parameter. Usually having 2 neighbors settled gives good/clean results, but also decreases significantly the number of detections. The other approach would be o decrease this number to 1. For this situation, more false positives will appear, but tweaking the NMS algorithm parameters usually will give good results.
Any contribution is welcomed!
/Enjoy.