import pygame import pygame.camera import time def capture(camera_stream = "/dev/video0", camera_res = (640, 480)): pygame.camera.init() pygame.camera.list_cameras() cam = pygame.camera.Camera(camera_stream, camera_res) cam.start() time.sleep(5) img = cam.get_image() pygame.image.save(img, './capture.jpg') cam.stop() return './capture.jpg'