import cv2 def snapshot(path, index=0): cap=cv2.VideoCapture(index); ok,frame=cap.read(); cap.release() if not ok: raise RuntimeError('Impossible de lire la caméra locale') cv2.imwrite(path,frame); return path