Digital Wanderers



Friday, May 2, 2008

How to Access USB Video Camera with Python for Windows XP

Here is a step by step guide on accessing USB Camera(Webcam) with Python and Python Imaging Library(PIL).
(For Windows platform).

1. Download and install Python 2.5 from here. You can choose the folder C:\Python25 for installation.

2. Download the zip file Videocapture from Sourceforge here.
Open the zip file and copy the vidcap.pyd in DLLs to C:\Python25\DLLs and files in Lib to C:\Python25\Lib folders respectively.

3. Download and run the EXE Python Imaging Library 1.1.6 for Python 2.5. You can run this exe from any folder.

The installation is over. Now you are ready to access the USB camera.

4. Open the GUI for Integrated Development Environment(IDLE) by Start -> Programs -> Python 2.5 > IDLE (Python GUI).

You can take a snapshot by executing three command lines only:

>> from VideoCapture import Device
>> cam = Device()
>> cam.saveSnapshot('Snap.jpg')

Snap.jpg file will be stored in the root folder C:\Python25.
It can be viewed by MS Paint.

PIL - Python Image Libray is a collection of files to manipulate images.
You can find a tutorial
here Python Imaging Library Handbook.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home