[python] 擷取視訊鏡頭
發表於 : 2022-01-27, 14:39
參考資料:https://www.itread01.com/content/1545212010.html
延伸閱讀:https://shengyu7697.github.io/python-opencv-resize/
使用openCV
pip install opencv-python
Code
延伸閱讀:https://shengyu7697.github.io/python-opencv-resize/
使用openCV
pip install opencv-python
Code
代碼: 選擇全部
import cv2
cap = cv2.VideoCapture(0) #開啟攝像頭
while(1):
# get a frame
ret, frame = cap.read()
# show a frame
cv2.imshow("capture", frame) #生成攝像頭視窗
if cv2.waitKey(1) & 0xFF == ord('q'): #如果按下q 就截圖儲存並退出
cv2.imwrite("D:/test.png", frame) #儲存路徑
break
cap.release()
cv2.destroyAllWindows()