Capture Guide
Using
You can list the installed capture devices using:
int imVideoCaptureDeviceCount(void) const char* imVideoCaptureDeviceDesc(int device)
If a device was removed or added in run time, you must update the list calling:
int imVideoCaptureReloadDevices(void)
To handle devices you must create a imVideoCapture structure using the function imVideoCaptureCreate. With this handle you can manage any of the available devices, but only one device. The handle must be destroyed with imVideoCaptureDestroy.
If you want to access two or more devices at the same time you must create two different structures, but be aware that this usually work for high quality devices like Firewire and USB 2.0. Webcams that use USB1.x can be used if connected to different USB 2.0 controllers.
The next thing is to connect to a specific device, because all the other remaining functions depends on this connection. Just call imVideoCaptureConnect with one of the available capture device numbers.
You control when a device start processing frames using imVideoCaptureLive. Once live the frames can be captured using imVideoCaptureFrame. Or you can use imVideoCaptureOneFrame, it will start capturing, returns the captured frame and stop capturing.
But before capturing a frame you may want to configure the device. You can do it using Attributes, or at least in Windows you can do it using the configuration dialogs with a call to imVideoCaptureShowDialog.
A very simple sequence of operations to capture just one frame from the first device available:
imVideoCapture* vc = imVideoCaptureCreate(); if (!imVideoCaptureConnect(vc, 0)) return; int width, height; imVideoCaptureGetImageSize(vc, &width, &height); // initializes the data pointer void* data = malloc(width*height*3); imVideoCaptureOneFrame(vc, data, IM_RGB); imVideoCaptureDestroy(vc);
The capture library is completely independent from the other libraries. It just uses the same description of the data buffer used in imFileReadImageData.
Building
You should include the <im_capture.h> header and link with the "im_capture.lib" library. This library is independent of all IM libraries.
To link with the capture library in Windows using Visual C you will need the file "strmiids.lib". To link it using Dev-C++ or Mingw 3 you will need the "im_capture.dll".
To compile the capture source code you will need the Direct X 9 SDK. Notice that since Direct X uses COM, CoInitialize(NULL) is called when the devices are enumerated.
For more information on Direct X capture, i.e. Direct Show see:
http://msdn.microsoft.com/library/en-us/directx9_c/directX/htm/directshow.asp