Ask Your Question

Revision history [back]

click to hide/show revision 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.")

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.")

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.")

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.")

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.")

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.")