项目作者: fvilmos

项目描述 :
Non-Maximum-Suppression - with OpenCV cascade classifier. Uses Intersection Over Union to filter potential detections.
高级语言: Python
项目地址: git://github.com/fvilmos/cascade_nms.git
创建时间: 2020-12-22T16:34:24Z
项目社区:https://github.com/fvilmos/cascade_nms

开源协议:GNU General Public License v3.0

下载


Non-Maximum-Suppression - cascade

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.



400

Green - all detections, red - filtered results. For more customization see the next sections.

How to use

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:

  1. /data/cascade.xml
  1. usage: test_cascade_nms.py [-h] [-cam CAM] [-n N] [-s S] [-iou IOU] [-so SO]
  2. [-rev REV]
  3. Cascade tester. Defaults: -cam 0 -n 0 -s 1.1 -iou 0.1
  4. optional arguments:
  5. -h, --help show this help message and exit
  6. -cam CAM Camera ID
  7. -n N Number of neighbors for detections
  8. -s S Scale factor
  9. -iou IOU Intersection Over Union threshold
  10. -so SO Sort the detection based on their area, bigest the last
  11. -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.

TODO

  • Update NMS algorithm to accept an array of probabilities, for use cases with deep neuronal networks.
  • introduce the “Soft-NMS” for probability tuning - see paper [1]

Any contribution is welcomed!

Resources

  1. Improving Object Detection With One Line of Code
  2. Cascade tool - automate the retraining of cascade classifiers with OpenCV

/Enjoy.