久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 OpenCV 進行圓檢測

Circle detection with OpenCV(使用 OpenCV 進行圓檢測)
本文介紹了使用 OpenCV 進行圓檢測的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何提高以下圓圈檢測代碼的性能

How can I improve the performance of the following circle-detection code

from matplotlib.pyplot import imshow, scatter, show
import cv2

image = cv2.imread('points.png', 0)
_, image = cv2.threshold(image, 254, 255, cv2.THRESH_BINARY)
image = cv2.Canny(image, 1, 1)
imshow(image, cmap='gray')

circles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, 2, 32)
x = circles[0, :, 0]
y = circles[0, :, 1]

scatter(x, y)
show()

使用以下源圖片:

我已嘗試調整 HoughCircles 函數的參數,但它們會導致誤報過多或誤報過多.特別是,我無法在兩個斑點之間的間隙中檢測到虛假圓圈:

I have tried adjusting the parameters of the HoughCircles function but they result in either too many false positives or too many false negatives. In particular, I am having trouble with spurious circles being detected in the gap between the two blobs:

推薦答案

@Carlos,在您所描述的情況下,我并不是 Hough Circles 的忠實粉絲.老實說,我覺得這個算法很不直觀.在您的情況下,我建議使用 findContour() 函數,然后計算質心.因此,我稍微調整了霍夫的參數以獲得合理的結果.在 Canny 之前,我還使用了一種不同的預處理方法,因為除了那個特定的情況之外,我看不出該閾值在任何其他情況下如何工作.

@Carlos, I'm not really a big fan of Hough Circles in situations like the one you've described. To be honest, I find this algorithm very unintuitive. What I would recommend in your case is using findContour() function and then calculating mass centers. Thus said, I tuned the Hough's parameters a bit to get reasonable results. I also used a different method for preprocessing before Canny, since I don't see how that thresholding would work in any other case than that particular one.

霍夫法:

尋找質心:

還有代碼:

from matplotlib.pyplot import imshow, scatter, show, savefig
import cv2

image = cv2.imread('circles.png', 0)
#_, image = cv2.threshold(image, 254, 255, cv2.THRESH_BINARY)
image = cv2.GaussianBlur(image.copy(), (27, 27), 0)
image = cv2.Canny(image, 0, 130)
cv2.imshow("canny", image)
cv2.waitKey(0)
imshow(image, cmap='gray')

circles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, 22, minDist=1, maxRadius=50)
x = circles[0, :, 0]
y = circles[0, :, 1]

scatter(x, y)
show()
savefig('result1.png')
cv2.waitKey(0)

_, cnts, _ = cv2.findContours(image.copy(), cv2.RETR_EXTERNAL,
    cv2.CHAIN_APPROX_SIMPLE)

# loop over the contours
for c in cnts:
    # compute the center of the contour
    M = cv2.moments(c)
    cX = int(M["m10"] / M["m00"])
    cY = int(M["m01"] / M["m00"])

    #draw the contour and center of the shape on the image
    cv2.drawContours(image, [c], -1, (125, 125, 125), 2)
    cv2.circle(image, (cX, cY), 3, (255, 255, 255), -1)

cv2.imshow("Image", image)
cv2.imwrite("result2.png", image)
cv2.waitKey(0)

這兩種方法都需要一些更精細的調整,但我希望這能給你更多的工作.

Both methods require some more fine tuning but I hope that gives you something more to work with.

來源:這個答案和pyimagesearch.

這篇關于使用 OpenCV 進行圓檢測的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 在线免费观看亚洲 | 性一交一乱一透一a级 | 国产久| 成人一区二区三区在线观看 | 亚洲精品中文字幕在线观看 | 黄色精品 | 久久机热 | 99精品九九 | 久久精品99 | 国产精品二区三区在线观看 | 亚洲91精品 | 国产日韩欧美一区二区 | 天堂中文在线播放 | 人妖av| 国产精品欧美一区二区三区不卡 | 免费一级黄色电影 | 欧美激情a∨在线视频播放 成人免费共享视频 | 欧美一区二区三区久久精品视 | 在线观看视频一区二区三区 | 精品视频一区二区在线观看 | 亚洲国产成人av | 日韩久草| 波多野结衣一区二区 | 亚洲狠狠| 国产成人免费视频网站高清观看视频 | 在线免费观看黄a | 九九伦理片 | 精品国产一区二区三区久久狼黑人 | 亚洲伊人精品酒店 | 国产一区二区在线免费观看 | 亚洲视频三区 | 欧美一区二区在线播放 | 伊人久久综合 | 精品一二三区 | 91精品久久久久久久 | 精品久久久久久亚洲精品 | 日韩精品久久一区二区三区 | 国产69精品久久99不卡免费版 | 国产999精品久久久 日本视频一区二区三区 | 亚洲美女一区 | 久久天堂网 |