分类器对 opencv 人脸检测器的置信度
我在 python 中使用 opencv 的 har 级联人脸检测器 (cv.HaarDetectObjects)。
例如:
faces = cv.HaarDetectObjects(grayscale, cascade, storage, 1.2, 2,
cv.CV_HAAR_DO_CANNY_PRUNING, (50,50))
for f in faces:
print(f)
这将以这种形式打印检测列表:
((174, 54, 114, 114), 53)
((22, 51, 121, 121), 36)
((321, 56, 114, 114), 21)
((173, 263, 125, 125), 51)
((323, 272, 114, 114), 20)
((26, 271, 121, 121), 36)
其中每行代表一个检测。前 4 个数字是左上角点的 x、y 位置,以及边界框的高度和宽度。最后一个数字是(引用自 openCV 文档)邻居的数量。
我想我有两个问题:
1)最后一个数字是什么意思?我在谷歌搜索时找不到任何相关参考。
2)(更重要)有没有办法获得每次检测的置信度分数?面部分类器在多大程度上确定检测对应于真实面部?
谢谢
I'm using opencv's har cascade face detector (cv.HaarDetectObjects) in python.
for example:
faces = cv.HaarDetectObjects(grayscale, cascade, storage, 1.2, 2,
cv.CV_HAAR_DO_CANNY_PRUNING, (50,50))
for f in faces:
print(f)
This will print a list of detections in this form:
((174, 54, 114, 114), 53)
((22, 51, 121, 121), 36)
((321, 56, 114, 114), 21)
((173, 263, 125, 125), 51)
((323, 272, 114, 114), 20)
((26, 271, 121, 121), 36)
Where each line represent a detection. The first 4 numbers are the x,y location of the top-left point, and the height, width of the bounding box. The last number is (quoting from the openCV documentation) the number of neighbors.
I guess I have two questions:
1) What does the last number mean? I couldn't find any reference to that when googling.
2) (more important)Is there a way to get a confidence score for each detection? How much is the face classifier certain that the detection corresponds to a real face?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1) 检测代码对一个对象产生多个检测 - 例如以不同的比例、稍微偏移等。然后将检测分组,并且该组中的邻居的数量就是返回的数量。另请参见 Viola Jones 论文,第 5.6 段 (http: //research.microsoft.com/en-us/um/people/viola/Pubs/Detect/violaJones_IJCV.pdf)和 OpenCV 源代码。
2)您可以使用邻居的数量作为某种置信度。
1) The detection code produces more than one detection for an object - e.g. in different scales, slightly shifted, etc. The detections are then grouped and the number of neighbours in such a group is the number returned. See also Viola Jones paper, paragraph 5.6 (http://research.microsoft.com/en-us/um/people/viola/Pubs/Detect/violaJones_IJCV.pdf) and OpenCV source.
2) You can possibly use the number of neighbours as some measure of confidence.
非常感谢您的提问和回答,我一直在寻找具有置信度分数的 opencv 人脸检测一天。您的问题和回答为我解决问题提供了一些指导。
正如 Palmstrom 所说,最后一个数字表示该簇中对象位置的数量。您可以将其用作置信度得分。
据我所知,旧的Python API中只有这种API。新的API没有这个(集群中对象的数量)值。
我把我的代码放在这里,以防它对其他人有所帮助。这是一个旧的 python API,其教程很难找到。
Thanks a lot for your question and answer, I have been looking for a opencv face detection with confidence scores for a day. Your question and answer give me some guidance to solve the problem.
Like Palmstrom said, the last number means the number of object positions in that cluster. and you can use that as confidence score.
As far as I know, there is only such kind of API in the old python API. New API does not have this (number of object in the cluster) value.
I put my code here in case it will help some other people. This is a old python API whose tutorial is hard to find.