import cv2 as cv
import numpy as np
def detect_circle_demo(image):
#边缘保留滤波 去噪
dst=cv.pyrMeanShiftFiltering(image,10,90)
cv.imshow("dst_pyrMeanShiftFiltering", dst)
gray=cv.cvtColor(dst,cv.COLOR_BGR2GRAY)
Circles=cv.HoughCircles(gray,cv.HOUGH_GRADIENT,1,20,param1=60,param2=28,minRadius=0,maxRadius=0)
circles=np.uint16(np.around(Circles))
for i in circles[0,:]:
cv.circle(image,(i[0],i[1]),i[2],(0,0,255),2)
cv.circle(image, (i[0], i[1]), 2, (255, 0, 0), 2)
cv.imshow("detect_circle_demo",image)
src=cv.imread("circle.png")
cv.namedWindow("src_01",cv.WINDOW_AUTOSIZE)
cv.imshow("src_01",src)
detect_circle_demo(src)
cv.waitKey(0)
cv.destroyAllWindows()
霍夫检测原理
最新推荐文章于 2025-06-14 14:43:18 发布