Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

Detect ellipses, ovals in images with OpenCV python

$
0
0
Hello everyone, I am using opencv to detect shapes that look like circles, my script reads a png image (center_cut.png) and perfectly detects the circles with their centroids, however when I pass another image where the circles are no longer perfect does not recognize them (left_cut). I would like to know if there is any way to detect shapes similar to circles, could someone please guide me? My code is as follows: import cv2 import numpy as np img = cv2.imread('center_cut.png',0) img = cv2.medianBlur(img,5) cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR) circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1, 50, param1=80,param2=20,minRadius=3,maxRadius=25) circles = np.uint16(np.around(circles)) for i in circles[0,:]: # Dibuja la circusnferencia del círculo cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) # dibuja el centro del círculo cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3) cv2.imshow('círculos detectados',cimg) cv2.waitKey(0) cv2.destroyAllWindows() ![image description](/upfiles/15749167072992786.png) ![image description](/upfiles/15749167412575266.png)

Viewing all articles
Browse latest Browse all 2088

Trending Articles