I have a code here that detects a white object using open cv moments. what i want is if that object is in the upper part of the webcam for 5 seconds. I want to do something .. Then if that object is seen in the bottom part of the webcam i want to do something also (but different) My webcam is 640x480 btw.
if moments['m00'] > 0:
x = int(moments['m10'] / moments['m00'])
y = int(moments['m01'] / moments['m00'])
if x > 0 and x <=640 and y > 0 and y <=240: #if it detects the object in the upper part
#count til 5 seconds then do something
else:
#if the object is in the lower part of webcam. Do something after 5 seconds
else:
#cancel the timer so it wont do the something