我的Python代码有问题。首先,当我使用函数pygame.get_image
时,我的网络摄像头的屏幕截图是NoneType
,但我需要它是一个表面或至少是一个图像,这样我才能转换它。这是我的密码:
import pygame
import pygame.camera
from pygame.locals import *
pygame.init()
pygame.camera.init()
cam=pygame.camera.Camera(0,(640,480),"RGB")
cam.start()
while 1:
screen=pygame.display.set_mode((640,480))
im=cam.get_image()
screen.blit(im,(0,0))
pygame.display.update
错误信息是:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
TypeError: argument 1 must be pygame.Surface, not None
如果
pygame.camera.Camera(0,(640,480),"RGB")
0
看起来不像设备,请尝试调用pygame.camera.list_cameras()以获取设备列表。你知道吗请记住,此模块仅适用于带有V4L2摄像头的Linux。你知道吗
相关问题 更多 >
编程相关推荐