Python opencvでカメラを開く

2147 ワード

import cv2
import numpy as np #   
cap = cv2.VideoCapture(0) #      0                    ,    1,2,3....
while True:   #      
	ret,frame = cap.read() #           frame 
	cv2.imshow('frame',frame) # frame                     ,    
	c = cv2.waitKey(1) #           'Q'     ,   
	if c == ord('q'):
		break
cap.release()  #    
cv2.DestroyAllWindows()

開く効果