웹캠 영상 출력 샘플코드

 

#   웹캠 영상 출력 윈도우 만들기

import cv2

def display_webcam_display():
    video_capture = cv2.VideoCapture(0)
    while True:
        # Grab a single frame of video
        status, frame = video_capture.read()

        if not status:
            break

        # Display the resulting image
        cv2.imshow('Video', frame)

        # Hit 'q' on the keyboard to quit!
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # Release handle to the webcam
    video_capture.release()
    cv2.destroyAllWindows()


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    display_webcam_display()