Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

python pygame.camera.init() NO vidcapture

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.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()

Yet 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:Python27libsite-packagespygamecamera.py", line 67, in init
    _camera_vidcapture.init()
  File "C:Python27libsite-packagespygame\_camera_vidcapture.py", line 21, in init
    import vidcap as vc
ImportError: No module named vidcap

PLS HELP!!! Im on Windows

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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-5VideoCapture-0.9-5Python27DLLs) to "your python path"DLLs .

3.restart you script.

Done!.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...