使用Python和OpenCV模組來讀取視訊鏡頭 安裝OpenCV pip install opencv-python 匯入OpenCV import cv2 建立視訊鏡頭物件 cap = cv2.VideoCapture(0) 持續讀取影像幀 while True: ret, frame = cap.read() cv2.imshow('Video', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break 釋放資源 cap.release() 關閉視窗 cv2.destroyAllWindows()