snipplets.dev/code/Python/opencv/capture.py

25 lines
416 B
Python
Raw Normal View History

2023-09-03 12:44:02 +03:00
#!/usr/bin/env python3
import cv2
2023-09-26 23:58:27 +03:00
RTSP_ADDR = 'rtsp://localhost:8554/cam'
DEVICE_ADDR = 2
cam = cv2.VideoCapture(DEVICE_ADDR)
2023-09-03 12:44:02 +03:00
while True:
result, image = cam.read()
cv2.imshow('Camera', image)
if cv2.waitKey(1) & 0xFF == ord('s'):
cv2.imwrite('capture.png', image)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cam.release()
2023-09-26 23:58:27 +03:00
2023-09-03 12:44:02 +03:00
cv2.destroyWindow('Camera')
cv2.destroyAllWindows()