Skip to content

Instantly share code, notes, and snippets.

@makkes
Created January 2, 2021 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makkes/ee77160dde6233f27240dca33bbe7c3b to your computer and use it in GitHub Desktop.
Save makkes/ee77160dde6233f27240dca33bbe7c3b to your computer and use it in GitHub Desktop.
import cv2 as cv
import time
delay = 5
if __name__ == "__main__":
cap = cv.VideoCapture("/dev/video2")
if not cap.isOpened():
print("Cannot open camera")
exit(1)
next_grab = time.time()
while True:
ret, frame = cap.read()
frame = cv.rotate(frame, cv.ROTATE_90_CLOCKWISE)
frame = frame[350:550, 0:800]
if not ret:
print("Cannot receive stream")
exit(1)
if time.time() - next_grab > 0:
cv.imshow("frame", frame)
cv.imwrite(str(int(time.time())) + ".png", frame)
next_grab = time.time() + delay
if cv.waitKey(1) == ord('q'):
cap.release()
cv.destroyAllWindows()
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment