我正在使用相机,使用 pygame,我编写了以下代码:
import pygame.camera
import pygame.image
pygame.camera.init()
list_webCam = pygame.camera.list_cameras()
webcam = pygame.camera.Camera(list_webCam[0],(640,480))
webcam.start()
img = webcam.get_image()
pygame.image.save(img, "photo.jpg")
pygame.camera.quit()
但它返回给我这个错误:
Traceback (most recent call last):
File "C:\Users\Fulvio\Desktop\pygame.Camera.py", line 11, in <module>
pygame.image.save(img, "photo.jpg")
TypeError: must be pygame.Surface, not None