On Mon, Sep 01, 2014 at 10:20:02PM +0700, Whees Northbee wrote: > for contour, hier in zip(contours, hierarchy): > (x,y,w,h) = cv2.boundingRect(contour)
What is the value of y here? Insert a line "print(x, y, w, h)" so you can see what values they take. > if w > 10 and h > 15: Is this condition ever true? Perhaps this block of code never gets executed at all. > 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? > centroid=(cx,cy) > cv2.circle(frame,(int(cx),int(cy)),1,(0,255,0),-1) > dy=cy-170 #my first try to increase counter, not work > if dy==0: > if (cx<=320)and(cx>=70): > counter=counter+1 That's better written as: if 70 <= cx <= 320: counter += 1 > if cy==170: #my second try to increasing, not work too > counter=counter+1 What values does cy take? -- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor