从python调用opencv HoughCircles。错误:( - 5)无法识别的方法ID

时间:2013-06-15 20:51:15

标签: python opencv

使用pytonxy安装的python和opencv

我正在尝试调用HoughCircles,但收到以下错误:

OpenCV Error: Bad argument (Unrecognized method id) in unknown function, file ..\..\..\OpenCV-2.4.2\modules\imgproc\src\hough.cpp, line 1069
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
cv2.error: ..\..\..\OpenCV-2.4.2\modules\imgproc\src\hough.cpp:1069: error: (-5) Unrecognized method id

代码非常简单:

import cv2
import matplotlib.pyplot as plt
vidCap =cv2.VideoCapture("D:\movies\VID_20130614_143125.mp4")
b, im = vidCap.read()

gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray, 1, cv2.cv.CV_HOUGH_GRADIENT, 100)

1 个答案:

答案 0 :(得分:1)

根据documentation,看起来好像dpmethod是位置参数,并且您的顺序错误。

所以而不是:

circles = cv2.HoughCircles(gray, 1, cv2.cv.CV_HOUGH_GRADIENT, 100)

应该是:

circles = cv2.HoughCircles(gray, cv2.cv.CV_HOUGH_GRADIENT, 1, 100)