On Tue, Sep 02, 2014 at 01:15:59AM +0700, Whees Northbee wrote: > There's no vehicle in my code, my video just contain vehicles so I think I > don't need to use haar classifier, so I'm just do background subtraction to > get foreground which is vehicle movement because there's no other movement > except vehicle and maybe little movement from trees...
Do you realise that this is a list for learning Python? We're not experts on video analysis. Probably nobody here except you has even the faintest idea what a Haar classifier is or whether you need one or not. > I just use opencv module, like to do background subtraction.. > No, the code don't have any error. If the code doesn't have any errors, then it must be working correctly. > The code is working smoothly to detecting vehicle and make rectangle of > vehicle, How do you know? What part of your code shows you that it is correctly detecting vehicles? > and I find center point of rectangle at (cx,cy).. > I draw manually a line in video at coordinate (20,170) to (320,170).. > When each of the rectangle vehicle cross or intersect with that line, I > want to count it as 1.. > I already try: > > *)I think, since the line is in the same y coordinate, so if the center > (cx,cy), cy=line y coordinate, the count increase > > if cy==170: > counter=counter+1 > > it doesn't work, no error but the counter stuck at 0 How fast are the vehicles moving? What is the resolution of the measurements? > Second try: > *)I try to find distance between (cx,cy) and that line, if the distance is > 0, counter increase > > dy=cy-170 #170 is y coordinate of line > if dy==0: > if (cx<=320) and (cx>=70): > counter=counter+1 > > don't have error, but the counter sometime add sometime no.. Earlier, you said that it never worked. Now you say it sometimes works. Which is correct? There is no difference between: cy == 170 and (cy - 170) == 0 So the question is, how do you know that cy ever equals 170? Suppose the vehicle is moving towards the line. In the first frame, cy = 300. In the second frame, 250. In the third frame, 200. Then, 150, 100, 50 and then it's no longer in the picture. There is never a time that cy == 170. The logic of your code is wrong. You need to think of a different way to solve this problem. Or, I could be completely wrong. I don't know, because I don't understand how this video processing works. I am just guessing. -- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor