기계는 거짓말하지 않는다

Python OpenCV 웹캠 실시간 읽기 본문

Python

Python OpenCV 웹캠 실시간 읽기

KillinTime 2021. 7. 31. 15:57

Python의 OpenCV를 이용하여 웹캠을 실시간으로 읽어 올 수 있다.

import cv2
import numpy as np
# 0 = default camera, 1 or more = additional camera
capture = cv2.VideoCapture(0)
# 3 = height, 4 = width 크기 설정
capture.set(3, 720)
capture.set(4, 1080)
while True:
# ret = True or False, frame = numpy array
ret, frame = capture.read()
cv2.imshow('test', frame)
k = cv2.waitKey(1)
# ord('q'): input q exit
if k == 27: # esc
break
capture.release()
cv2.destroyAllWindows()

'Python' 카테고리의 다른 글

Python Index Error  (0) 2021.08.03
Python ValueError: invalid literal for int() with base 10  (0) 2021.08.02
Python OpenCV Error Sequence item with index 0 has a wrong type  (0) 2021.07.31
Python glob module  (0) 2021.07.29
Python os module  (0) 2021.07.29