Ask Your Question
0

Measuring the diameter of circles

asked 2020-10-02 04:27:33 -0600

kilwa gravatar image

updated 2020-10-02 10:19:38 -0600

I am currently doing circle detection on images look like this one, image description is there a way to calculate the diametre of each circles, and count the number of circles in image?

edit retag flag offensive close merge delete

Comments

(I can't see any circles in the image, do it might be hard for OpenCv too...)

mvuori gravatar imagemvuori ( 2020-10-02 07:24:22 -0600 )edit

yes you're right. i updated my image to be more clear.

kilwa gravatar imagekilwa ( 2020-10-02 08:58:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-10-02 10:18:57 -0600

updated 2020-10-02 20:04:26 -0600

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:

image description

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()
edit flag offensive delete link more

Comments

yes i want to. how can i use it with python please?

kilwa gravatar imagekilwa ( 2020-10-02 11:11:30 -0600 )edit

you need to compile OpenCV with contrib. did you do it before?. what is your OS ?

sturkmen gravatar imagesturkmen ( 2020-10-02 11:13:38 -0600 )edit
sturkmen gravatar imagesturkmen ( 2020-10-02 14:11:58 -0600 )edit

ok i will try. thanks alot.

kilwa gravatar imagekilwa ( 2020-10-02 14:12:54 -0600 )edit

this is really tough to find the equivalent in python !! any guide lines ?

kilwa gravatar imagekilwa ( 2020-10-02 16:47:38 -0600 )edit

how to install edlib in virtual environment using anaconda ?

kilwa gravatar imagekilwa ( 2020-10-03 16:36:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-10-02 04:27:33 -0600

Seen: 3,469 times

Last updated: Oct 02 '20