OpenCV detectMultiScale()minNeighbors参数 [英] OpenCV detectMultiScale() minNeighbors parameter

查看:326
本文介绍了OpenCV detectMultiScale()minNeighbors参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Haar分类器来检测对象. 在途中,我不明白什么是minNeighbors参数,什么是 它代表什么? 其实我不知道检测的邻居是什么 候选矩形.请问有人可以定义附近的想法吗?

I'm currently using Haar classifiers, to detect objects. On my way, I didn't understand what is the minNeighbors parameter, what is it representing? Actually I don't understand what are the neighbors of the detection candidate rectangle. Please can anybody define the neighboring idea?

推荐答案

Haar级联分类器与滑动窗口方法一起使用.如果查看级联文件,您会看到一个size参数,该参数通常是一个非常小的值,例如2020.这是级联可以检测到的最小窗口.因此,通过应用滑动窗口方法,您可以将窗口滑动通过整个图片,而不是调整其大小并再次搜索,直到无法进一步调整其大小为止.因此,在每次迭代中,haar的级联分类器都会存储真实输出.因此,当此窗口在图片中滑动时,将调整大小并再次滑动;它实际上检测到许多误报.您可以通过给 minNeighbors 0 来检查其检测到的内容.这里有个例子:

Haar cascade classifier works with a sliding window approach. If you look at the cascade files you can see a size parameter which usually a pretty small value like 20 20. This is the smallest window that cascade can detect. So by applying a sliding window approach, you slide a window through out the picture than you resize it and search again until you can not resize it further. So with every iteration haar's cascaded classifier true outputs are stored. So when this window is slided in picture resized and slided again; it actually detects many many false positives. You can check what it detects by giving minNeighbors 0. So an example here :

因此,由于调整了滑动窗口的大小以及很多误报,因此出现了很多人脸检测.因此,为了消除误报并从检测中获得正确的人脸矩形,应用了邻域方法.就像它在其他矩形附近而不是可以的一样,您可以进一步传递它.因此,此数字确定将多少个邻域作为面矩形传递需要多少.在同一张图片中,当 1 :

So there are a lot of face detection because of resizing the sliding window and a lot of false positives too. So to eliminate false positives and get the proper face rectangle out of detections, neighborhood approach is applied. It is like if it is in neighborhood of other rectangles than it is ok, you can pass it further. So this number determines the how much neighborhood is required to pass it as a face rectangle. In the same image when it is 1 :

因此,通过增加此数字,您可以消除误报,但要小心,通过增加此数字,您也可能会丢失真实的正数. 3 是完美的结果:

So by increasing this number you can eliminate false positives but be careful, by increasing it you can also lose true positives too. When it is 3 a perfect result :

这篇关于OpenCV detectMultiScale()minNeighbors参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆