使用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)
答案 0 :(得分:1)
根据documentation,看起来好像dp
和method
是位置参数,并且您的顺序错误。
所以而不是:
circles = cv2.HoughCircles(gray, 1, cv2.cv.CV_HOUGH_GRADIENT, 100)
应该是:
circles = cv2.HoughCircles(gray, cv2.cv.CV_HOUGH_GRADIENT, 1, 100)