【发布时间】:2014-07-03 09:55:42
【问题描述】:
这是我第一次尝试图像处理,请多多包涵。我正在尝试运行以下python example 来查找图像中的所有霍夫圆。但是,当我收到以下错误时:
OpenCV 错误:错误标志(参数或结构字段)(无法识别或 不支持的数组类型)在 cvGetMat,文件 /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/array.cpp,第 2482 行 Traceback(最近一次通话最后一次):文件“hough_circles.py”,第 10 行, 在 param1=50,param2=30,minRadius=0,maxRadius=0) cv2.error: /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/array.cpp:2482: 错误:(-206)函数中无法识别或不支持的数组类型 cvGetMat
下面是我的代码:
import cv2
import cv2.cv as cv # here
import numpy as np
img = cv2.imread('opencv-logo.png',0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(img,cv.CV_HOUGH_GRADIENT,1,20,
param1=50,param2=30,minRadius=0,maxRadius=0)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
# draw the outer circle
cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('detected circles',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
这是我尝试使用的opencv-logo.jpg 图像。你能帮我运行这个例子并指导我遍历每个找到的圆的半径吗?
谢谢
【问题讨论】:
标签: python opencv image-processing