6 - 5
Image Capture
Sample 7 - A synchronous image capture
// Capture image specifies:
for capture - Photo Mode and Lights On During Frames.
for Transfer - Subsample value of 1 and Lossless transfer.
Note: You don’t really have to pass anything except the HHP_IMAGE structure as long as you
want the imager config settings for capture and transfer. Also, no progress feedback will
be received.
HHP_IMAGE image; // Structure to hold captured image
HHP_IMAGE_TRANSFER imgTrans; // Image transfer options (override
imager config)
// Image capture options (override
imager config)
TCHAR tcErrMsg[ 128 ]; // Error message buffer
Result_t nResult = RESULT_ERR_INTIALIZE; // Return code
// Make sure to set imgAcqu structure size!
imgAcqu.dwStructSize = sizeof( HHP_IMAGE_ACQUISITION );
// Set the mask to activate captureMode and illuminatCycle (lights).
ImgAcqu.dwMask = (ILLUMINATION_DUTY_CYCLE_MASK | IMAGE_CAPTURE_MODE_MASK);
// Set values
ImgAcqu.captureMode = HHP_AUTOEXPOSURE_PHOTO;
ImgAcqu. IlluminatCycle = HHP_DUTY_CYCLE_ON;
// Make sure to set imgTrans structure size!
imgTrans.dwStructSize = sizeof( HHP_IMAGE_TRANSFER );
// Set the subsample and compression masks.
ImgTrans.dwMask = (SUBSAMPLE_VALUE_MASK | COMPRESSION_MODE_MASK);
// Set values
imgTrans.dwSubSample = 1;
imgTrans. compressionMode = COMPRESSION_LOSSLESS;
// Set the HHP_IMAGE structure size and allocate a buffer for the data, set the buffer
size and how you want to receive the data in the buffer.
Image.dwStructSize = sizeof( HHP_IMAGE );
Image.puchBuffer = new BYTE[ 324000 ]; // Allocate a buffer big enough to hold
640x480x8 plus header (if BMP)
Image.nBufferSize = 324000; // SDK wants to know how big the buffer
so no overflow.
Image.fileFormat = FF_RAW_GRAY; // 8 bit raw data.
// Call the SDK function to capture an image setting the bWait parameter to TRUE for
blocking/synchronous behavior.
if ( (nResult = hhpAcquireImage( &image,&imgTrans, &imgAcqu,TRUE ) == RESULT_SUCCESS )
{
// Display the image. NOTE: you could specify FF_BMP_GRAY. The data would come as
a BMP file.
}
else
{
hhpGetErrorMessage( nResult,tcErrMsg );
_tprintf( _T(“Image Capture Failed: %s\n”),tcErrMsg );