Ask Your Question
0

opencv-python>>Template Matching with Multiple Objects

asked 2018-05-24 12:28:50 -0600

chuan gravatar image

updated 2018-05-24 13:59:00 -0600

in the example,what does pt[0] and pt[1] mean??

for pt in zip(*loc[::-1]):
        cv2.rectangle(img, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)
        counter=counter+1

Umm...I guess it means initial point in the picture,but how do program know the initial point should be?

Can anyone help me to answer my question? Thank you in advance.

edit retag flag offensive close merge delete

Comments

link to the example ?

berak gravatar imageberak ( 2018-05-24 12:46:24 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-05-24 14:22:05 -0600

updated 2018-05-24 14:23:58 -0600

I assume you got the code from here

The result from zip(*loc[::-1]) is a tuple that is stored in pt. At this point, pt has the structure (x, y) and p[0] == x and p[1] == y.

Now, let's take a turn and look at OpenCV documentation of cv2.rectangle(). You will see that the third and fourth arguments are of type Point. A peek into Point shows that its attributes are x,y. In Python, this type definition is encapsulated into a tuple since data type declaration is not a thing.

I think this is enough for you to put two and two together and understand exactly what that drawing function does.

Happy coding, Cheers mate :)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-05-24 12:28:50 -0600

Seen: 958 times

Last updated: May 24 '18