python pygame.camera.init() NO vidcapture

后端 未结 4 566
小鲜肉
小鲜肉 2021-01-02 21:36

I am trying to initialize the camera module in pygame and display video from a usb webcam. This is my code:

import pygame
import pygame.camera
from pygame.ca         


        
相关标签:
4条回答
  • 2021-01-02 21:49

    I met the same problem but I found out that its not included on windows ONLY LINUX

    0 讨论(0)
  • 2021-01-02 21:52

    I met the same problem. The error info of "ImportError: No module named vidcap" indicates that python interpreter didn't find the vidcap module on you machine.

    so you'd better follow these steps.

    1. Download the vidcap from http://videocapture.sourceforge.net/

    2.Then copy the corresponding version of dll (which named "vidcap.pyd" in VideoCapture-0.9-5\VideoCapture-0.9-5\Python27\DLLs) to "your python path"\DLLs\ .

    3.restart you script.

    Done!.

    0 讨论(0)
  • 2021-01-02 22:02

    The camera module can only be used on linux

    0 讨论(0)
  • 2021-01-02 22:10

    Try this:

    import pygame
    
    import pygame.camera
    
    import time, string
    
    
    from VideoCapture import Device
    
    from pygame.locals import *
    
    pygame.camera.init()
    
    cam = pygame.camera.Camera(0,(640,480),"RGB")
    
    cam.start()
    
    img = pygame.Surface((640,480))
    
    cam.get_image(img)
    
    pygame.image.save(img, "img2.jpg")
    
    cam.stop()
    
    0 讨论(0)
提交回复
热议问题