Skip to content

Instantly share code, notes, and snippets.

@Park-Developer
Created December 27, 2021 16:45
Show Gist options
  • Save Park-Developer/30908465ce93c84100d467eb21764f7b to your computer and use it in GitHub Desktop.
Save Park-Developer/30908465ce93c84100d467eb21764f7b to your computer and use it in GitHub Desktop.
opencv : camera setting
import cv2
cap=cv2.VideoCapture(0) # 카메라 0번 장치 연결
width=cap.get(cv2.CAP_PROP_FRAME_WIDTH) # 프레임 폭
height=cap.get(cv2.CAP_PROP_FRAME_HEIGHT) # 프레임 높이
print("Original Size",width,height)
cap.set(cv2.CAP_PROP_FRAME_WIDTH,320)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT,240)
width=cap.get(cv2.CAP_PROP_FRAME_WIDTH) # 프레임 폭
height=cap.get(cv2.CAP_PROP_FRAME_HEIGHT) # 프레임 높이
print("Resized Size",width,height)
if cap.isOpened():
while True:
ret, img=cap.read()
if ret:
cv2.imshow("Test",img)
if cv2.waitKey(1)!=-1: #1ms동안 키 입력 대기 =>아무키나 누르면 중지
break
else:
break
else:
print("Can't Open Video")
cap.release() # 캡쳐 자원 반납납
cv2.detroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment