【问题标题】:How should I solve my problem with "np.around" method?我应该如何用“np.around”方法解决我的问题?
【发布时间】:2019-11-12 20:00:01
【问题描述】:

我正在尝试使用以下代码使用 openCv 检测图像中的圆圈:

import cv2
import numpy 

im = cv2.imread('/home/elessar/bottle .jpg')

gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)

blur = cv2.medianBlur(gray, 5)

circles = cv2.HoughCircles(blur, cv2.HOUGH_GRADIENT, 1.5, 10, param1 = 100, param2 = 100 ,minRadius = 20, maxRadius = 60)
circles = np.uint16(np.around(circles))

for i in circles[0, :]:
    cv2.circle(im, (i[0], i[1]), i[2], (255,0,0), 2)
    cv2.circle(im, (i[0], i[1]), 2, (0,255,0), 5)


cv2.imshow('detected_circle', im)
cv2.waitKey(0)
cv2.destroyAllWindows()

我收到了这个错误:

'NoneType' 对象没有属性 'rint'

我应该怎么做才能解决这个问题?

【问题讨论】:

  • this post 有帮助吗?
  • 我已经尝试过了,但没有成功。

标签: python numpy opencv


【解决方案1】:

cv2.HoughCircles (circles) 的结果是None。你应该处理没有找到圆圈的情况。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-24
    • 1970-01-01
    • 2021-06-04
    • 1970-01-01
    • 1970-01-01
    • 2020-03-25
    • 2020-02-14
    • 2021-08-19
    相关资源
    最近更新 更多