1 | initial version |
you can just use python's builtin time() function to do this, it's really trivial:
import cv2
import time
t0 = time.time() # start time in seconds
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
t1 = time.time() # current time
num_seconds = t1 - t0
if num_seconds > 30: # e.g. break after 30 seconds
break
2 | No.2 Revision |
you can just use python's builtin time() function to do this, it's really trivial:
import cv2
import time
t0 = time.time() # start time in seconds
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
cv2.imshow('frame',frame)
## uncomment, if you *want* the preview
if #cv2.imshow('frame',frame)
#if cv2.waitKey(1) & 0xFF == ord('q'):
# break
t1 = time.time() # current time
num_seconds = t1 - t0
t0 # diff
if num_seconds > 30: # e.g. break after 30 seconds
break
3 | No.3 Revision |
you can just use python's builtin time() function to do this, it's really trivial:
import cv2
import time
t0 = time.time() # start time in seconds
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
## uncomment, if you *want* the preview
#cv2.imshow('frame',frame)
#if cv2.waitKey(1) & 0xFF == ord('q'):
# break
... processing or preview
t1 = time.time() # current time
num_seconds = t1 - t0 # diff
if num_seconds > 30: # e.g. break after 30 seconds
break