python - 无霍夫圆检测
问题描述
我已经使用 Circle Hough 变换来检测此图像中的圆圈,通过在 python 中使用此代码,但现在我想通过使用另一种方法来检测圆圈,除了圆圈 Hough 变换之外,还有其他方法可以检测圆圈吗
import cv2
import numpy as np
img = cv2.imread("Resources/coin0.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur= cv2.medianBlur(gray, 5)
# center
dp=1.1
minDis=10
param1=150
param2=40
minRadius=0
maxRadius=0
circles = cv2.HoughCircles(blur, cv2.HOUGH_GRADIENT, dp, minDis,
param1 =param1, param2 =param2, minRadius = minRadius, maxRadius = maxRadius)
circles = np.uint16(np.around(circles))
for i in circles[0, :]: ## Draw circle on the circles
# draw the outer circle
cv2.circle(img, (i[0], i[1]), i[2], (0, 255, 0),2)
# draw the center of the circle
cv2.circle(img, (i[0], i[1]), 2, (0, 0, 255),2)
cv2.imshow("Image",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
解决方案
推荐阅读
- machine-learning - 机器学习预处理中的大范围数据缩放
- php - 从位置 0 而不是 10 开始
- php - PHP 条件和循环正在破坏 html 格式
- java - 错误 java.lang.NoSuchMethodError: No such DSL method '***' found between steps
- system-verilog - 如果“break”在fork-join内,如何打破循环?
- python-3.x - Elasticsearch 批量插入不完全工作
- r - 如何解析出特定的文本部分?
- java - 在不删除重复项的情况下对树集进行排序
- javascript - 创建一个 Promise 循环
- git - 我有什么选择来处理这个分支场景?