Sensors & Effectors/Camera

[OpenCV][Python] Show video

jstar0525 2021. 7. 12. 14:24
반응형

Check the Camera

$ ls /dev/video*

 

Show video

import cv2

src = '/dev/video0'
W, H, fps = 1920, 1080, 30

cap = cv2.VideoCapture(src)
cap.set(3, W)
cap.set(4, H)
cap.set(5, fps)

while(True):
    ret, frame = cap.read()

    if ret:
        cv2.imshow('video', cv2.resize(frame, dsize=(960, 540)))

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    else:
        break

cap.release()
cv2.destroyAllWindows()
반응형