目的 Mac内蔵カメラの動画をpythonでキャプチャした際の備忘録です。 準備 環境:mac os x 10.13 High Sierra python3 opencv2ライブラリ コード カメラから動画を撮影するのコードそのまま実行して動きました。 グレイスケール画像表示は下記 import numpy as np import cv2 cap = cv2.VideoCapture(0) while(True): # Capture frame-by-frame ret, frame = cap.read() # Our operations on the frame come here gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Display the resulting frame cv2.imshow('frame',gray