使用pygame启动网络摄像头

问题描述 投票:0回答:1

我是python和pygame的新手。我试图用pygame打开网络摄像头。我有以下代码。

    import pygame, sys
    import pygame.camera as camera
    from pygame.locals import *

    pygame.init()
    camera.init()

    screen=pygame.display,set_mode((640,480))

    cam=pygame.camera.Camera("/dev/video0",(640,480))
    cam.start()

    while 1:
        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()

有一个错误说:

    File "F:\camera", line 6, in <module>

    camera.init()

    File "C:\Python27\lib\site-packages\pygame\camera.py", line 42, in init

    import _camera

    ImportError: No module named _camera

我在网上搜索过,但他们都使用了这个。任何帮助将不胜感激。

谢谢。

python pygame
1个回答
0
投票

你正在使用Windows。

From the documentation

Pygame目前仅支持Linux和v4l2相机。

所以你无法做到这一点。

© www.soinside.com 2019 - 2024. All rights reserved.