当我尝试从python中的pygame
导入相机模块时,我收到导入错误。我正在使用Pycharm。
错误是:
Traceback (most recent call last)
line 6, in <module>
pygame.camera.init()
AttributeError: 'module' object has no attribute 'camera'
Process finished with exit code 1
代码是 -
#!/usr/bin/python
import pygame, sys
from pygame.locals import *
pygame.init()
pygame.camera.init()
screen = pygame.display.set_mode((640,480))
cam = pygame.camera.Camera("/dev/video0",(640,480))
cam.start()
while True:
image = cam.get_image()
screen.blit(image,(0,0))
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()