Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Wrong detection of Circle when using cv2.minEnclosingCircle

$
0
0

I am trying to detect and draw a circle in somes grayscale images using OpenCV. The Canny Edge Detection works perfectly, but for some reason the circle derived the points in the Canny fit horribly. I accept any suggestions for detecting the circle or that might sole

Here is the code I used(sorry for the weird variable names in portuguese)

masc_limbo = cv2.imread(path_masc_limbo)gray = cv2.cvtColor(roi_masc, cv2.COLOR_BGR2GRAY)canny = cv2.Canny(gray , 100, 200)cv2_imshow(canny)points = np.argwhere(canny > 0)center, raio = cv2.minEnclosingCircle(points)center= (int(center[0]), int(center[1]) )raio = int(raio)cv2.circle(roi_masc, center, 1, (255, 200, 0), 3)cv2.circle(roi_masc, center, raio, (255, 0, 255), 2)cv2_imshow(roi_masc)

Canny result:

Canny result:

Enclosing Circles result:

Enclosing Circles result:


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>