You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
518 B
24 lines
518 B
import pygame
|
|
import pygame.camera
|
|
import time
|
|
|
|
import cv2
|
|
|
|
def capture(camera_stream = 0, camera_res = (1920, 1080)):
|
|
cam = cv2.VideoCapture(camera_stream)
|
|
s, img = cam.read()
|
|
|
|
if s:
|
|
cv2.imwrite('./capture.jpg', img)
|
|
# 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'
|
|
|
|
|