Created
January 2, 2021 20:36
-
-
Save makkes/ee77160dde6233f27240dca33bbe7c3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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