【问题标题】:How I can get correctly return value from HoughCircles如何从 HoughCircles 获得正确的返回值
【发布时间】:2023-03-11 06:55:01
【问题描述】:

我从 GitHub 克隆了 this 项目,但它现在不起作用。我还不知道 HoughCircles opencv (cv2) 函数返回 None 的原因。

谁能帮我理解 HoughCircles 并解决这个问题?谢谢。

img = cv2.imread('download.png', 1)
#img=cv2.resize(img,None,fx=2, fy=2, interpolation = cv2.INTER_CUBIC)
img_grayscale=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
img_inverse=cv2.bitwise_not(img_grayscale)

#Circle Detection Part
circles = cv2.HoughCircles(img_inverse,cv2.HOUGH_GRADIENT,1,20,param1=50,param2=200,minRadius=0,maxRadius=0)
circles = np.uint16(np.around(circles))

【问题讨论】:

标签: python python-3.x opencv computer-vision


【解决方案1】:

如果圆圈为无,则表示您的图像未返回其中存在的任何圆圈。另外,上传 img 以便更好地理解。 对于这个错误,你可以这样做

if circle is not None:
    circles = np.uint16(np.around(circles))

【讨论】:

    猜你喜欢
    • 2018-07-26
    • 2014-09-05
    • 1970-01-01
    • 2017-02-07
    • 1970-01-01
    • 2023-02-22
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多