问题描述
我在Raspberry Pi上的HSV过滤的PiCamera提要上运行HoughCircles()
,以检测到粉红色的球.有时我会得到[[[0. 0. 0.]]]
的ndarray结果,该结果与np.zeros(shape=(1, 1, 3))
相同,而不是在相机视图中没有圆形时所期望的None
.我看了看文档,但是没有看到为什么它会返回这个的任何细节.我也查看了源代码,但找不到 C ++代码,这似乎也无济于事.
I'm running HoughCircles()
on an HSV filtered PiCamera feed on a Raspberry Pi to detect a pink ball. Occasionally I will get a ndarray result of [[[0. 0. 0.]]]
which is the same as np.zeros(shape=(1, 1, 3))
, rather than the expected None
when there is no round shape in the camera's view. I looked at the docs but didn't see any details on why it would return this. I also looked at the source but can't find the Python wrapper for the C++ code, which doesn't seem to help me either.
这是我的函数调用:
circles = cv2.HoughCircles(frame, cv2.HOUGH_GRADIENT, 3, frame.shape[0] / 4, param1=220, param2=110, minRadius=5)
我想知道为什么它会做一些事情,例如识别我什至在imshow()
上都看不到的小东西(它总是在(0,0)周围全黑;几十行和一列什么也没有,零),那么为什么它总是在半径为0的(0,0)处?我提供minRadius=5
时,看不到它将如何返回半径为0的圆.我不认为这实际上是一种有效的检测方法.有时候要执行数百次操作,但看来我可以通过快速移动相机之类的东西(例如我的手)来触发它.
I'm wondering why if it's doing something like identifying something incredibly small that I can't even see on the imshow()
(which is always completely black around (0,0); dozens of rows and columns of nothing but zeros), then why is it always at (0,0) with a radius of 0? I don't see how it would return the circle with a radius of 0 when I supplied minRadius=5
. I don't believe this is actually a valid detection. Sometimes it takes hundreds of executions for this to happen but it seems that I can trigger it by moving something by the camera quickly such as my hand.
有什么想法为什么会发生这种情况,也许有人经历过这种情况?
Any ideas why this is happening, maybe somebody else has experienced this?
推荐答案
我在C ++中遇到了一个相同的问题,其中HoughCircles()将为某些图像返回一个带有单个[0,0,0]的列表.已发现这是由OpenCV的RemoveOverlaps()方法中的错误引起的,并将在以后的版本(例如3.4.7、4.2.0等)中修复.
I ran into an identical issue in C++ where HoughCircles() would return a list with a single [0,0,0] in it for certain images. This was found to be caused by a bug in the RemoveOverlaps() method in OpenCV and will be fixed in future releases (e.g. 3.4.7, 4.2.0, etc).
如果您需要更多信息,请查看我编写的错误报告: https://github.com/opencv/opencv/issues/14432
If you want more info, take a look at the bug report that I wrote:https://github.com/opencv/opencv/issues/14432
这篇关于OpenCV HoughCircles偶尔返回[0. 0. 0.]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!