tags:

views:

412

answers:

3

I have this garden variety USB video camera, and it came with two mini-apps, one that just lets you see what the camera sees, and one that records to an .avi file.

But what's the API if I want to grab images from the camera in my own C program? I am making the assumptions that it's (1) possible and (2) desirable to make some call and have a 2D array of pixel information filled in.

What I really want to do is tinker with image processing algorithms, and for that I'd really like to get my code around some live data.

EDIT -

Having had a healthy exposure to Linux, I can grasp how (ideally/in theory) you could open() the device, use ioctl() to configure it, and read() the data. And I'm virtually certain that that's not how Windows is going to present the API. Not knowing what function names Windows might use for a video device API, or even if it has one, makes it difficult to look up, at least with the win32 api search capabilities that I have at my disposal.

+1  A: 

You'll probably need the DirectShow API, provided that's how the camera operates. If the manufacturer created their own code path, you'll need their API.

A. Scagnelli
A: 

The API is the way to go.

A good indication of whether the camera requires a bespoke one or not is to see if it is recognised by a PC without the manufacturer's applications installed. If windows has the drivers built in the you should be able to use the windows APIs to capture the images.

Alternatively if you know what compression codec has been used for the AVI file you could unpack it.

Ideally it would be good if you could capture the video in native (YUV, RGB15 or similar) format as then you can work on compression as well as manipulation.

ChrisBD
A: 

Your first step, as pointed out by ChrisBD, is to check if Windows supports your device.

If that is the case you have three possible Windows APIs for capture:

  • DirectShow
  • VFW. Has more or less been replaced by DirectShow
  • MediaFoundation. Is the newest API that is intended to replace DirectShow. AFAIK not fully implemented yet and only available in Vista.

From the three DirectShow is the best choice. However, learning and using DirectShow is not a trivial task. An excellent example can be found here.

Another possibility is to use OpenCV. OpenCV is an image processing library, that you can also use for processing the images. OpenCV has an image capture API that provides a simpler abstraction and is easier to use than the Windows APIs.

Dani van der Meer