python - OpenCV 霍夫圆变换检测球体
2020-12-25 06:28
标签:str median code 有用 nbsp radius open loading res 重要的是理解霍夫圆变换过程:https://en.wikipedia.org/wiki/Circle_Hough_Transform opencv 调参没什么意义,仅对我使用的图像有用。 测试图像: 图片来源:http://www.kevinbeason.com/smallpt/ python - OpenCV 霍夫圆变换检测球体 标签:str median code 有用 nbsp radius open loading res 原文地址:https://www.cnblogs.com/darkchii/p/13207833.htmlimport cv2 as cv
im = cv.imread(‘../result_25k.png‘, cv.IMREAD_COLOR)
im_gray = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
im2 = cv.medianBlur(im_gray, 5)
circles = cv.HoughCircles(im2, cv.HOUGH_GRADIENT, 2, im_gray.shape[1] / 8, 100, 130, minRadius=0, maxRadius=0)
print(circles)
for i in circles[0, :]:
cv.circle(im, (i[0], i[1]), 1, (0, 255, 0), 2)
cv.circle(im, (i[0], i[1]), i[2], (0, 128, 255), 2)
cv.imshow(‘im‘, im)
cv.waitKey(0)
cv.destroyAllWindows()
cv.imwrite(‘../result.png‘, im)
文章标题:python - OpenCV 霍夫圆变换检测球体
文章链接:http://soscw.com/index.php/essay/38096.html