Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python OpenCV plot circles at a list of centre coordinates

I have been able to generate a list of coordinates that i would like to use as the centres of mulltiple small circles that i would like to plot on an image.

I am able to plot circles at individual points but have not been able to find the correct syntax for plotting circles at all of the centres. The coordinates i wish to use for the centres are stored as follows, in an array named Points which has a shape :(11844, 2)

[[  5   5]
 [  5  10]
 [  5  15]
 ..., 
 [630 460]
 [630 465]
 [630 470]]

I am able to plot an individual circle by using the following code:

cv2.circle(frame1,(5,5),1,(0,0,255))

I have tried to plot all points by using :

cv2.circle(frame1,Points[:,:],1,(0,0,255))

This gives back this error though:

cv2.circle(frame1,Points[:,:],1,(0,0,255))
SystemError: new style getargs format but argument is not a tuple

Am i supposed to be using a loop to step through all the points and plot them one by one? If so which loop should I use? Or is there something simple that i am missing?

like image 784
James Mallett Avatar asked Jul 03 '16 20:07

James Mallett


2 Answers

I managed to find the answer with help from Joel using the following code:

    for point in Points:
        cv2.circle(frame1,tuple(point),1,(0,0,255))
like image 109
James Mallett Avatar answered Oct 01 '22 15:10

James Mallett


Try this, it should work:

for point in Points:
    cv2.circle(frame1, point, 1,(0,0,255))
like image 20
vinu chandran Avatar answered Oct 01 '22 15:10

vinu chandran