Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Extracting circle centre coordinates using cv2.HoughCircles

$
0
0
Hi there! I want to extract centre coordinates of detected circles using cv2. HoughCircles, here's the code- import cv2 import numpy as np def f(x): return img = cv2.imread('C:/Users/Yardy/img1.png') cimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) edges = cv2.Canny(cimg,50,150,apertureSize=3) circles = cv2.HoughCircles(edges, cv2.HOUGH_GRADIENT, 1.2, 200,param2=30) if circles is not None: circles = np.round(circles[0, :]).astype("int") X = circles print X When I run this code, in X I get the centre coordinates as well as the radius of the circle. How do I store the coordinates and radius in separate variables? Also if my code detects more than one circle, I get an error - >Need more than one value to repack. Can anybody help me?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



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