Impact Acquire SDK C++
Capturing Image Data Using Older Compilers Or In Complex Applications

To capture an image an instance of the class mvIMPACT::acquire::FunctionInterface must be created. This class can be constructed by passing a pointer to the mvIMPACT::acquire::Device object obtained from the mvIMPACT::acquire::DeviceManager to the class constructor.

The function interface class provides access to most of the devices executable functions, while most of the settings (e.g. the exposure time or the trigger mode) are implemented as properties (see e.g. mvIMPACT::acquire::Property for details).

//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
//-----------------------------------------------------------------------------
{
if( devMgr.deviceCount() == 0 )
{
cout << "No device found! Unable to continue!" << endl;
char ch = getch();
return 0;
}
cout << "Initializing the device. This might take some time..." << endl;
// create an interface to the first device found
mvIMPACT::acquire::Device* pDev = devMgr[0];
try
{
pDev->open();
}
{
// this e.g. might happen if the same device is already opened in another process...
cout << "An error occurred while opening the device(error code: " << e.errCode()
<< "). Press any key to end the application..." << endl;
char ch = getch();
return 0;
}
// send a request to the default request queue of the device and wait for the result.
fi.imageRequestSingle();
// Start the acquisition manually if this was requested(this is to prepare the framework for data capture and tell the device to start streaming data)
if( pDev->acquisitionStartStopBehaviour.read() == assbUser )
{
if( ( result = static_cast<TDMR_ERROR>(fi.acquisitionStart()) ) != DMR_NO_ERROR )
{
cout << "'FunctionInterface.acquisitionStart' returned with an unexpected result: " << result
<< "(" << ImpactAcquireException::getErrorCodeAsString( result ) << ")" << endl;
}
}
// wait for results from the default capture queue
int requestNr = fi.imageRequestWaitFor( -1 );
// check if the image has been captured without any problems
if( !fi.isRequestNrValid( requestNr ) )
{
// If the error code is -2119(DEV_WAIT_FOR_REQUEST_FAILED), the documentation will provide
// additional information under TDMR_ERROR in the interface reference
cout << "imageRequestWaitFor failed (" << requestNr << ", " << ImpactAcquireException::getErrorCodeAsString( requestNr ) << ")"
<< ", timeout value too small?" << endl;
}
const mvIMPACT::acquire::Request* pRequest = fi.getRequest(requestNr);
if( !pRequest->isOK() )
{
cout << "ERROR! Request result: " << pRequest->requestResult.readS() << endl;
return 0;
}
// everything went well. Do whatever you like with the result
const int width = pRequest->imageWidth.read();
// unlock the buffer to let the framework know that you no longer need this buffer
fi.imageRequestUnlock( requestNr );
return 0;
}
Grants access to devices that can be operated by this software interface.
Definition mvIMPACT_acquire.h:7171
unsigned int deviceCount(void) const
Returns the number of devices currently present in the system.
Definition mvIMPACT_acquire.h:7400
This class and its functions represent an actual device detected by this interface in the current sys...
Definition mvIMPACT_acquire.h:6118
void open(void)
Opens a device.
Definition mvIMPACT_acquire.h:6420
PropertyIAcquisitionStartStopBehaviour acquisitionStartStopBehaviour
An enumerated integer property defining the start/stop behaviour during acquisition of this driver in...
Definition mvIMPACT_acquire.h:6800
ZYX read(int index=0) const
Reads a value from a property.
Definition mvIMPACT_acquire.h:4300
The function interface to devices supported by this interface.
Definition mvIMPACT_acquire.h:10758
A base class for exceptions generated by Impact Acquire.
Definition mvIMPACT_acquire.h:256
std::string readS(int index=0, const std::string &format="") const
Reads data from this property as a string.
Definition mvIMPACT_acquire.h:3340
Contains information about a captured buffer.
Definition mvIMPACT_acquire.h:8640
bool isOK(void) const
Convenience function to check if a request has been processed successfully.
Definition mvIMPACT_acquire.h:9474
PropertyIRequestResult requestResult
An enumerated integer property (read-only) defining the result of this request.
Definition mvIMPACT_acquire.h:9780
PropertyI imageWidth
An integer property (read-only) containing the width of the image in pixels.
Definition mvIMPACT_acquire.h:10320
TDMR_ERROR
Errors reported by the device manager.
Definition mvDriverBaseEnums.h:2601
@ DMR_NO_ERROR
The function call was executed successfully.
Definition mvDriverBaseEnums.h:2603

This sample contains everything the user needs to do to capture one image including all initialization work and error handling for every source of error one can think of.

Note
A much more specific summary of the available sample applications can be found at the Typical Usage Scenarios And Example Applications page.

Several example applications will provide an even better understanding of the interface.

The 'GenICam' vs. 'DeviceSpecific' Interface Layout chapter will provide more details on how to work with properties.