如何在Cv2中使用Hough圈和python? [英] how to use hough circles in cv2 with python?
本文介绍了如何在Cv2中使用Hough圈和python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,我想检测圆.
I have the following code and I want to detect the circle.
img = cv2.imread("act_circle.png")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray,cv2.CV_HOUGH_GRADIENT)
它似乎没有属性,并且错误如下
it looks like it does not have the attribute and the error is the following
'module' object has no attribute 'CV_HOUGH_GRADIENT'
有人知道这个隐藏参数在哪里吗?
Does anybody know where this hidden parameters is?
谢谢
推荐答案
CV_HOUGH_GRADIENT
属于cv
模块,因此您需要导入该文件:
CV_HOUGH_GRADIENT
belongs to the cv
module, so you'll need to import that:
import cv2.cv as cv
并将函数调用更改为
circles = cv2.HoughCircles(gray,cv.CV_HOUGH_GRADIENT)
这篇关于如何在Cv2中使用Hough圈和python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文