Measuring the diameter of circles
I am currently doing circle detection on images look like this one, is there a way to calculate the diametre of each circles, and count the number of circles in image?
I am currently doing circle detection on images look like this one, is there a way to calculate the diametre of each circles, and count the number of circles in image?
i suggest you to use ED_Lib which finds circles and ellipses efficiently. I want to add it in OpenCV Contrib but did not find enough time to complete yet. anyway i can help you if you want to add its source in OpenCV and use it with python.
you can test it if you compile OpenCV adding edlib directory in modules
sample python code produces the image below:
import cv2
img = cv2.imread('16016470376420309.jpg')
circles = cv2.testEDCircles(img)
if circles is not None: # Check if circles have been found and only then iterate over these and add them to the image
_a, b, _c = circles.shape
for i in range(b):
cv2.circle(img, (circles[0][i][0], circles[0][i][1]), circles[0][i][2], (0, 255, 0), 1, cv2.LINE_AA)
cv2.circle(img, (circles[0][i][0], circles[0][i][1]), 2, (0, 255, 0), 1, cv2.LINE_AA) # draw center of circle
# show the output image
cv2.imshow("output", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Asked: 2020-10-02 04:27:33 -0600
Seen: 3,469 times
Last updated: Oct 02 '20
Is it possible to draw half circle?
Remove defects from round object
I need a maxEnclosingCircle function
MSER Sample in OpenCV 2.4.2 on Visual Studio 2012
fast way to draw ellipse axes?
Is there something wrong with circle grid with patternSize of 4 * 3 ?
Rotated ellipse as structuring element.
Unexpected behavior of minEnclosingCircle
Calculating the mid point in a rotated rectangle side [closed]
(I can't see any circles in the image, do it might be hard for OpenCv too...)
yes you're right. i updated my image to be more clear.