![]() | 1 | initial version |
this is not really an opencv problem, more about your (lack of) general python skills, but it might go like this:
import time
timer = 0 # our variable for *absolute* time measurement
last_t = 0 # relative
while (True): #detection loop
now = time.time() # in seconds
dt = now - last_t
last_t = now
# try to detect person
if person_detected:
timer += dt # sum up
else:
timer = 0 # reset
if timer > 60:
print("you've been here for a minute.")
![]() | 2 | No.2 Revision |
this is not really an opencv problem, more about your (lack of) general python skills, but it might go like this:
import time
timer = 0 # our variable for *absolute* time measurement
last_t = 0 # relative
while (True): #detection # detection loop
now = time.time() # in seconds
dt = now - last_t
last_t = now
# try to detect person
if person_detected:
timer += dt # sum up
else:
timer = 0 # reset
if timer > 60:
print("you've been here for a minute.")
![]() | 3 | No.3 Revision |
this is not really an opencv problem, more about your (lack of) general python skills, but it might go like this:
import time
timer = 0 # our variable for *absolute* time measurement
last_t = 0 # relative
while (True): # detection loop
now = time.time() # in seconds
dt = now - last_t # diff time
last_t = now
now # cache
# try to detect person
if person_detected:
timer += dt # sum up
else:
timer = 0 # reset
if timer > 60:
print("you've been here for a minute.")
![]() | 4 | No.4 Revision |
this is not really an opencv problem, more about your (lack of) general python skills, but it might go like this:
import time
timer = 0 # our variable for *absolute* time measurement
last_t = 0 # relative
while (True): # detection loop
now = time.time() # in seconds
dt = now - last_t # diff time
last_t = now # cache
# try to detect person
if person_detected:
timer += dt # sum up
else:
timer = 0 # reset
if timer > 60:
print("you've been here for a minute.")
![]() | 5 | No.5 Revision |
this is not really an opencv problem, more about your (lack of) general python skills, but it might go like this:
import time
timer = 0 # our variable for *absolute* time measurement
last_t = 0 # relative
cache var
while (True): # detection loop
now = time.time() # in seconds
dt = now - last_t # diff time
last_t = now # cache
# try to detect person
if person_detected:
timer += dt # sum up
else:
timer = 0 # reset
if timer > 60:
print("you've been here for a minute.")
![]() | 6 | No.6 Revision |
this is not really an opencv problem, more about your (lack of) general python skills, but it might go like this:
import time
timer = 0 # our variable for *absolute* time measurement
last_t = 0 # cache var
while (True): # detection loop
now = time.time() # in seconds
dt = now - last_t # diff time
last_t = now # cache
# try to detect person
if person_detected:
timer += dt # sum up
else:
timer = 0 # reset
if timer > 60:
print("you've been here for a minute.")