[Tutor] How to count vehicle? I'm trying but my code don't increasing..

Steven D'Aprano steve at pearwood.info
Mon Sep 1 21:34:52 CEST 2014


On Tue, Sep 02, 2014 at 12:54:03AM +0700, Whees Northbee wrote:
> >What is the value of y here?
> (x,y,w,h)=cv2.boundingRect(contour), where x,y is the left up position from
> contour, and w,h is width and height of contour..

That's not the value of y. You have just repeated the same line of code 
that provides the values. What are they?

y = 1?

y = 100000?

Who knows? Do you know what values y has? 


> >*                 if w > 10 and h > 15:*
> 
> *this code I used, because there's a lot small blob from video
> shaking, or the movement of trees.. And yes, the condition is true*

How do you know?


> >*                     cv2.rectangle(frame, (x,y), (x+w,y+h), (180, 0, 0), 1)
> *>*                     x1=w/2      #to find centroid
> *>*                     y1=h/2
> *>*                     cx=x+x1
> *>*                     cy=y+y1*
> 
> >What's the value of cy?
> cy and cx is the coordinate of center of rectangle.. the value is cartesian
> coordinate like (136,60)

You're testing for cy == 170. If the value of cy is 60, that doesn't 
equal 170.


-- 
Steven


More information about the Tutor mailing list