pygame.camera.init()导入错误

时间:2015-07-26 02:35:30

标签: python camera pygame importerror

当我尝试从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()

0 个答案:

没有答案