An easy way to access webcam data in C++ (using Visual Studio 7.0)
- Douglas Summers-Stay

This is a video framework originally developed for http://www.iua.upf.es/mtg/reacTable/?portvideo.

Instructions:

  1. go to http://sourceforge.net/project/showfiles.php?group_id=127248&package_id=139292&release_id=379593

  2. Download PortVideoSDL-0.3.src.zip. Extract the files to a folder. Open PortVideoSDL-0.3/win32/portVideoSDL.vcproj (similar files exist in the package for linux or mac.)

  3. Build the project.

  4. Start(without debugging.)

  5. If that works, you can go in and change it. The fastest way is to go in and edit FrameInverter.cpp. Right now it simply loops through each pixel and inverts the brightness, but you can do any math you like with access to all the pixels (as a one dimensional array.)

In general there is a simple wrapper class CameraEngine and various subclasses for each platform and camera type. The CameraTool simply returns the chosen or first available camera, initializes it with the desired width, height and color depth. Once started, a new image buffer will be returned every time you call getFrame().

There is a simple SDL demo application included, which shows the basic usage of this framework. If you want to start right away, simply implement and add a subclass of FrameProcessor.[FrameInverter is such a subclass.] See the FrameInverter example source code for more information.

If you want to work in color, go into main.cpp and set bool colour = true;

Press t while the program is running to see the result image. Press s to see the source image.

It uses this http://www.ims.tuwien.ac.at/~thomas/dsvideolib.php library, which is included in the package.

For an example project using this, with more advanced capabilities, check out http://www.iua.upf.es/mtg/reacTable/?software