I am trying to extract points of the circumference of a circle

asked 2017-08-11 04:33:41 -0500

Santhosh1 gravatar image

updated 2017-08-11 05:38:16 -0500

berak gravatar image

Here I have created two arrays to store X and Y coordinates of the circumference (full 360 degrees)

#360 degree points of the circle
x_Pos = np.array(360)
y_Pos = np.array(360)

loop to to draw the circle and store the points on the circumference

for i in circles[0,:]:
# draw the outer circle
cv2.circle(img_inverted,(i[0],i[1]),i[2],(0,255,0),2)
x=i[0]
y=i[1]
r=i[2]
for j in range(0,360):
        x_Pos[j] = r*np.cos(np.radians(j)) + x
        y_Pos[j] = r*np.sin(np.radians(j)) + y
# draw the center of the circle
cv2.circle(img_inverted,(i[0],i[1]),6,(0,0,255),3)

I have this error show up when I try complying the code

IndexError                                Traceback (most recent call last)
<ipython-input-151-3241c5884c93> in <module>()
 26     r=i[2]
 27     for j in range(0,360):
 ---> 28             x_Pos[j] = r*np.cos(np.radians(j)) + x
 29             y_Pos[j] = r*np.sin(np.radians(j)) + y
 30     # draw the center of the circle

 IndexError: too many indices for array
edit retag flag offensive close merge delete