James Mallett
James Mallett

Reputation: 857

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?

Upvotes: 8

Views: 16412

Answers (3)

vinu chandran
vinu chandran

Reputation: 11

Try this, it should work:

for point in Points:
    cv2.circle(frame1, point, 1,(0,0,255))

Upvotes: 1

James Mallett
James Mallett

Reputation: 857

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))

Upvotes: 10

joel goldstick
joel goldstick

Reputation: 4493

Does this work:

for point in Points:
    cv2.circle(frame1, points, 1,(0,0,255))

Upvotes: 0

Related Questions