import cv2 # initialize the camera cap = cv2.VideoCapture(0, cv2.CAP_V4L2) # capture a frame ret, frame = cap.read() # release the camera cap.release() # save the captured frame cv2.imwrite('captured_image.jpg', frame)