 |
|
 |
|
|
|
 |
 |
 |
 |
Introduction
API Document
Sample Code
Video Grabber Library
Compilation Environment
- You have to include vdograb.h in your code, and call
CoInitialize(NULL) to initialize the COM use before calling any
routine of the library. Of course, you have better to call
CoUninitialize( ) when your application is about to terminated.
- You have to link strmiids.lib and one of vdograb.lib (for
release version) or vdograbd.lib (for debugging version). You
don't have to install DirectX SDK for for library because
strmiids.lib is already the necessary library extract from
DirectX 9.0c SDK.
Programming Interface
- After the web camera is properly linked to the computer, the
application calls GrabberOpen() to connect the camera device. If the
connection is successful, it returns TRUE.
The argument pFriendlyName is the name of the camera shown in the
hardware manager of the control panel. It specifies the camera
device to be connected when there are multiple cameras linked to the
computer. pFriendlyName can be NULL, and GrabberOpen() uses the
first found camera device automatically.
The prototype of the routine is:
BOOL GrabberOpen(wchar_t
*pFriendlyName, GRABBERCALLBACK pCallback);
And the prototype of the callback function pCallback isdefined:
typedef void
(*GRABBERCALLBACK)(void *pBits, int width, int height, int size);
This is a function provided by the application developer to receive
the captured images. The format of the images is uncompressed 24-bit
bottom-up DIB. Here is an example:
void MyCallback(void
*pBits, int width, int height, int size);
{
/* width and height are the dimensions
of the image, and size is the data
length of pBits. The
application renders pBits or copies pBits inside
the routine... */
}
/* Connect the first web camera by the
statement in main procedure of the
application. And ask the library to
transport the captured images to
MyCallback. */
GrabberOpen(NULL, MyCallback);
Remadk: The callback function and the
main procedure of application are running in different threads.
- After a successful GrabberOpen() call, the camera device is
connected but the video capturing is not started. It is started by
calling GrabberStart(), and the callback function pCallback starts
receiving the images.
The prototype of the routine is:
BOOL GrabberStart(void);
- To stop the video capturing, simply call GrabberStop(). It can
be re-started by another GrabberStart() call.
The prototype of the routine is:
void GrabberStop(void);
- When the application is about to be terminated, or it wants to
connect another camera device, call GrabberClose( ) to disconnect
the camera device connected by previous GrabberOpen( ) call.
The prototype of the routine is:
void GrabberClose(void);
Last updated at 2006 / 11 / 27 by Shu-Kai Yang.
|
|
 |
|
 |