使用 opencv 过滤目标检测的误报
我使用 opencv 的 HaarDetectObjects(...) 来检测图像中的对象。该函数返回图像中可能包含该对象的区域的坐标,问题是我只想检测图像中该对象的单个实例,并且我无法知道该函数返回的结果中的哪个是“最好的”。有没有一种方法可以让结果按实际包含该对象的概率排序?或者也许定义结果必须通过的某种阈值?基本上,我需要一种过滤掉误报的方法。
我不限于使用 opencv 或 HaarDetectObjects,如果有人对其他库或其他对象检测方法有建议,欢迎。
谢谢。
im using opencv's HaarDetectObjects(...) to detect an object in an image. The function returns the coordinates of areas in the image that might contain the object, the problem is i only want to detect a single instance of the object in the image and i have no way of knowing which of the results returned by the function is the "best". is there a way i could get the results sorted by their probability of actually containing the object ? or maybe define some sort of threshold the results must pass ? basically, i need a way of filtering out the false positives.
i am not restricted to using opencv or HaarDetectObjects, if anyone has a suggestion for another library or another object detection method, it is welcome.
thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以利用任何特定领域的知识吗?
如果预计对象具有特定大小或最有可能处于特定位置,您可以定义一个非常简单的索引来测量每次检测与该大小/位置的距离,这就是您的概率检测实际上是对象。
它预计具有某种颜色吗?您可以获取样本对象的颜色直方图。然后,您可以使用距离函数将 HaarDetectObjects 返回到此示例直方图的每个检测进行比较(对于距离函数,我的脑海中会弹出名称“Bhattacharyya distance”和“Mahalanobis distance”,但我不能声称任何专业知识OpenCv 确实支持 直方图,但包括 CompareHist 函数)。
关于物体的轮廓、纹理、几何形状……你有什么可以说的吗?任何可以简化为数字并与“基本值”进行比较的东西都可以有所帮助。
当然,所有这些都受到处理限制。其中一些建议在计算时间方面可能会或可能不会有点昂贵。这可能会也可能不会影响您的应用程序,具体取决于您是否有硬件或实时限制。
Is there any domain specific knowledge you can take advantage of?
If the object is expected to be of a certain size or is most likely to be in certain position, you can define a very simple index that measures how far each detection is from being that size/position, so that would be your probability of a detection actually being the object.
Is it expected to be of certain color? You can take the color histogram of a sample object. Then, you could compare each detection that HaarDetectObjects has returned to this sample histogram using a distance function (for the distance function, the names "Bhattacharyya distance" and "Mahalanobis distance" pop up in my mind, but I can't claim any expertise on this. OpenCv does have support for histograms, though, including a CompareHist function).
Is there anything you can say about the object's contours, texture, geometry...? Anything that can be reduced to numbers and compared to a "ground value" can be of help.
All of this, of course, is subject to processing constraints. Some of these suggestions might or might not be a bit expensive in terms of computation time. And this might or might not affect your application, depending of whether you have hardware or real time constraints.