Extracting circle centre coordinates using cv2.HoughCircles
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?
@jmbapps Didn't get a word of that... can you please elaborate? I think that C