Impact Acquire SDK C
Capturing Image Data

This short section shows how to capture and display a live image together with the output of some statistical information with this interface on Windows®.

The complete source code can be found in the examples section: ContinuousCapture.c (for the GenICam™ interface please refer to ContinuousCaptureGenICam.c instead).

First the library is initialized and a device is opened:

#define END_APPLICATION \
printf( "Press any key to end the application.\n" ); \
getch(); \
return 0; \
// try to initialize the library.
if( ( result = DMR_Init( &hDMR ) ) != DMR_NO_ERROR )
{
printf( "DMR_Init failed (code: %d)\n", result );
END_APPLICATION;
}
// try to get access to the first recognized device in the system
if( ( result = DMR_GetDevice( &hDevice, dmdsmSerial, "*", 0, '*' ) ) != DMR_NO_ERROR )
{
printf( "DMR_GetDevice failed (code: %d)\n", result );
END_APPLICATION;
}
// switch to GenICam interface layout if supported by the device. This is the recommended interface layout for new applications using GenICam compliant devices. It is also the default interface layout used by ImpactControlCenter and usually results in access to a richer feature set.
if( ( hPropInterfaceLayout = getDeviceProp( hDevice , "InterfaceLayout" ) ) != INVALID_ID )
{
setPropI( hPropInterfaceLayout, dilGenICam, 0 );
}
// try to initialize this device
if( ( result = DMR_OpenDevice( hDevice, &hDriverInterface ) ) != DMR_NO_ERROR )
{
printf( "DMR_OpenDevice failed (code: %d)\n", result );
END_APPLICATION;
}
@ DMR_NO_ERROR
The function call was executed successfully.
Definition mvDriverBaseEnums.h:2603
@ dmdsmSerial
Searches for a device with a certain serial number.
Definition mvDeviceManager.h:528
@ dilGenICam
A GenICamâ„¢ like interface layout shall be used.
Definition mvDriverBaseEnums.h:2150
MVDMR_API TDMR_ERROR DMR_CALL DMR_Init(HDMR *pHDmr)
Initialises the library.
Definition mvDeviceManager.cpp:1137
MVDMR_API TDMR_ERROR DMR_CALL DMR_OpenDevice(HDEV hDev, HDRV *pHDrv)
Initialises a device.
Definition mvDeviceManager.cpp:1516
MVDMR_API TDMR_ERROR DMR_CALL DMR_GetDevice(HDEV *pHDev, TDMR_DeviceSearchMode searchMode, const char *pSearchString, unsigned int devNr, char wildcard)
Tries to locate a certain device in the system which matches the input criteria.
Definition mvDeviceManager.cpp:1379
const int INVALID_ID
A constant to check for an invalid ID returned from the property handling module.
Definition mvPropHandlingDatatypes.h:62

In any thread function the handle to the device (HDEV) and the handle to the devices interface (HDRV) can now be used to capture images:

while( ( result = DMR_ImageRequestSingle( hDriverInterface, 0, 0 ) ) == DMR_NO_ERROR );
{
printf( "DMR_ImageRequestSingle: Unexpected error(code: %d(%s))\n", result, DMR_ErrorCodeToString( result ) );
}
while( !s_boTerminated )
{
result = DMR_ImageRequestWaitFor( hDriverInterface, 500, 0, &requestNr );
if( result == DMR_NO_ERROR )
{
if( ( result = DMR_GetImageRequestBuffer( hDriverInterface, requestNr, &pIB ) ) == DMR_NO_ERROR )
{
// display the captured image using some kind of display function
// inform the driver, that this request buffer is no longer needed by the user
DMR_ImageRequestUnlock( hDriverInterface, requestNr );
// request the next image
DMR_ImageRequestSingle( hDriverInterface, 0, 0 );
}
else
{
printf( "DMR_GetImageRequestBuffer: ERROR! Code %d\n", result );
}
}
else
{
printf( "DMR_ImageRequestWaitFor: ERROR! Code %d\n", result );
}
}
@ DEV_NO_FREE_REQUEST_AVAILABLE
The user requested a new image, but no free Request object is available to process this request.
Definition mvDriverBaseEnums.h:2713
MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestSingle(HDRV hDrv, int requestCtrl, int *pRequestUsed)
Sends an image request to the device driver.
Definition mvDeviceManager.cpp:2663
MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestUnlock(HDRV hDrv, int requestNr)
Unlocks the request for the driver again.
Definition mvDeviceManager.cpp:2727
MVDMR_API const char *DMR_CALL DMR_ErrorCodeToString(int errorCode)
Returns a string representation of a given error code.
Definition mvDeviceManager.cpp:5383
MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestBuffer(HDRV hDrv, int requestNr, ImageBuffer **ppBuffer)
Returns the ImageBuffer of the desired request.
Definition mvDeviceManager.cpp:3732
MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestWaitFor(HDRV hDrv, int timeout_ms, int queueNr, int *pRequestNr)
Waits for a request object to become ready.
Definition mvDeviceManager.cpp:2767