Python pygame.camera.init () NO vidcapture

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

import pygame import pygame.camera from pygame.camera import * from pygame.locals import * pygame.init() pygame.camera.init() cam = pygame.camera.Camera("/dev/video0",(640,480)) cam.start() image = cam.get_image() 

But I get this error:

 Traceback (most recent call last): File "C:/Users/Freddie/Desktop/CAMERA/Test1.py", line 7, in <module> pygame.camera.init() File "C:\Python27\lib\site-packages\pygame\camera.py", line 67, in init _camera_vidcapture.init() File "C:\Python27\lib\site-packages\pygame\_camera_vidcapture.py", line 21, in init import vidcap as vc ImportError: No module named vidcap 

HELP PLS !!! Im on windows

+4
source share
4 answers

I met the same problem. The error information "ImportError: No module named vidcap" indicates that the python interpreter did not find the vidcap module on your computer.

so you better follow these steps.

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

3. Repeat you script.

done !.

+4
source

Camera module can only be used on linux

+3
source

I met the same problem, but I found out that it is not included in Windows ONLY LINUX

+2
source

Try the following:

 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
source

All Articles