mvIMPACT Acquire SDK C++

The GenericInterfaceLayout.legacy program is a legacy version of the GenericInterfaceLayout.cpp example.

This is a legacy version of GenericInterfaceLayout.cpp only needed when working on a system with a non C++11 capable compiler (e.g. Visual Studio smaller then version 2013 or gcc smaller than version 4.8). For a detailed description please have a look on the modern version of this example. Even though the used C++ code is slightly different the general idea of the example is the same!
Source code
#ifdef _MSC_VER // is Microsoft compiler?
# if _MSC_VER < 1300 // is 'old' VC 6 compiler?
# pragma warning( disable : 4786 ) // 'identifier was truncated to '255' characters in the debug information'
# endif // #if _MSC_VER < 1300
#endif // #ifdef _MSC_VER
#include <iostream>
#include <algorithm>
#include <map>
#include <apps/Common/exampleHelper.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# include <mvDisplay/Include/mvIMPACT_acquire_display.h>
typedef void* ImageDisplayWindow;
#endif // #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
using namespace std;
using namespace mvIMPACT::acquire;
typedef map<string, Property> StringPropMap;
void populatePropertyMap( StringPropMap& m, Component it, const string& currentPath = "" )
while( it.isValid() )
string fullName( currentPath );
if( fullName != "" )
fullName += "/";
fullName +=;
if( it.isList() )
populatePropertyMap( m, it.firstChild(), fullName );
else if( it.isProp() )
m.insert( make_pair( fullName, Property( it ) ) );
// method object will be ignored...
void singleCapture( Device* pDev, const FunctionInterface& fi, ImageDisplayWindow* pDisp, int maxWaitTime_ms )
// send a request to the default request queue of the device and
// wait for the result.
manuallyStartAcquisitionIfNeeded( pDev, fi );
// wait for the image send to the default capture queue
int requestNr = fi.imageRequestWaitFor( maxWaitTime_ms );
// check if the image has been captured without any problems
if( fi.isRequestNrValid( requestNr ) )
const Request* pRequest = fi.getRequest( requestNr );
if( pRequest->isOK() )
// everything went well. Display the result...
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
pDisp->GetImageDisplay().SetImage( pRequest );
cout << "Image captured(" << pRequest-> << "x" << pRequest-> << ")" << endl;
// suppress compiler warnings
( void )pDisp;
#endif // #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
cout << "A request has been returned, but the acquisition was not successful. Reason: " << pRequest->requestResult.readS() << endl;
// ... unlock the request again, so that the driver can use it again
fi.imageRequestUnlock( requestNr );
cout << "The acquisition failed: " << ImpactAcquireException::getErrorCodeAsString( requestNr ) << endl;
manuallyStopAcquisitionIfNeeded( pDev, fi );
// in any case clear the queue to have consistent behaviour the next time this function gets called
// as otherwise an image not ready yet might be returned directly when this function gets called the next time
fi.imageRequestReset( 0, 0 );
bool isDeviceSupportedBySample( const Device* const pDev )
if( !pDev->interfaceLayout.isValid() )
return false;
vector<TDeviceInterfaceLayout> availableInterfaceLayouts;
pDev->interfaceLayout.getTranslationDictValues( availableInterfaceLayouts );
return find( availableInterfaceLayouts.begin(), availableInterfaceLayouts.end(), dilGenICam ) != availableInterfaceLayouts.end();
int main( void )
cout << "This sample is meant for devices that support the GenICam interface layout only. Other devices might be installed" << endl
<< "but won't be recognized by the application." << endl
<< endl;
DeviceManager devMgr;
Device* pDev = getDeviceFromUserInput( devMgr, isDeviceSupportedBySample );
if( !pDev )
cout << "Unable to continue! Press [ENTER] to end the application" << endl;
return 1;
cout << "Initialising the device. This might take some time..." << endl;
catch( const ImpactAcquireException& e )
// 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.getErrorCode() << ")." << endl
<< "Press [ENTER] to end the application" << endl;
return 1;
// create a function interface to the device
FunctionInterface fi( pDev );
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
// initialise a display window
ImageDisplayWindow* pDisp = new ImageDisplayWindow( "mvIMPACT_acquire sample" );
ImageDisplayWindow* pDisp = 0;
#endif // #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
// obtain all the settings related properties available for this device
// Only work with the 'Base' setting. For more information please refer to the manual (working with settings)
StringPropMap propertyMap;
DeviceComponentLocator locator( pDev, dltSetting, "Base" );
populatePropertyMap( propertyMap, Component( locator.searchbase_id() ).firstChild() );
locator = DeviceComponentLocator( pDev, dltRequest );
populatePropertyMap( propertyMap, Component( locator.searchbase_id() ).firstChild() );
locator = DeviceComponentLocator( pDev, dltSystemSettings );
populatePropertyMap( propertyMap, Component( locator.searchbase_id() ).firstChild(), string( "SystemSettings" ) );
locator = DeviceComponentLocator( pDev, dltInfo );
populatePropertyMap( propertyMap, Component( locator.searchbase_id() ).firstChild(), string( "Info" ) );
populatePropertyMap( propertyMap, Component( pDev->hDev() ).firstChild(), string( "Device" ) );
string cmd;
int timeout_ms = 500;
bool boRun = true;
while( boRun )
cout << "enter quit, snap, list, help or the name of the property you want to modify followed by [ENTER]: ";
cin >> cmd;
if( cmd == "snap" )
singleCapture( pDev, fi, pDisp, timeout_ms );
else if( cmd == "list" )
for_each( propertyMap.begin(), propertyMap.end(), DisplayProperty() );
else if( cmd == "help" )
cout << "quit: terminates the sample" << endl
<< "snap: takes and displays one image with the current settings" << endl
<< "list: displays all properties available for this device" << endl
<< "help: displays this help text" << endl
<< "timeout: set a new timeout(in ms) used as a max. timeout to wait for an image" << endl
<< "the full name of a property must be specified" << endl;
else if( cmd == "quit" )
boRun = false;
else if( cmd == "timeout" )
cout << "Enter the new timeout to be passed to the imageRequestWaitFor function: ";
cin >> timeout_ms;
const StringPropMap::const_iterator it = propertyMap.find( cmd );
if( it == propertyMap.end() )
cout << "unknown command or property" << endl;
displayPropertyData( it->second );
if( it->second.hasDict() )
cout << "This function expects the string representation as input!" << endl;
modifyPropertyValue( it->second );
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
// free resources
delete pDisp;
#endif // #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
return 0;
std::string name(void) const
Returns the name of the component referenced by this object.
Definition: mvIMPACT_acquire.h:1089
A base class to implement access to internal driver components.
Definition: mvIMPACT_acquire.h:1321
bool isValid(void) const
Checks if the internal component referenced by this object is still valid.
Definition: mvIMPACT_acquire.h:1603
bool isProp(void) const
Checks if this component is of type mvIMPACT::acquire::Property or a derived type.
Definition: mvIMPACT_acquire.h:1588
bool isList(void) const
Checks if this component is of type mvIMPACT::acquire::ComponentList.
Definition: mvIMPACT_acquire.h:1568
Component firstChild(void) const
Moves to the first child of this component(moves down one level).
Definition: mvIMPACT_acquire.h:1477
A class to locate components within the driver.
Definition: mvIMPACT_acquire.h:7832
Grants access to devices that can be operated by this software interface.
Definition: mvIMPACT_acquire.h:6964
This class and its functions represent an actual device detected by this interface in the current sys...
Definition: mvIMPACT_acquire.h:5948
void open(void)
Opens a device.
Definition: mvIMPACT_acquire.h:6238
HDEV hDev(void) const
A unique identifier for this device.
Definition: mvIMPACT_acquire.h:6136
PropertyIDeviceInterfaceLayout interfaceLayout
An enumerated integer property which can be used to define which interface layout shall be used when ...
Definition: mvIMPACT_acquire.h:6444
ZYX read(int index=0) const
Reads a value from a property.
Definition: mvIMPACT_acquire.h:4170
const EnumPropertyI & getTranslationDictValues(std::vector< ZYX > &sequence) const
This function queries a list of valid values for this property.
Definition: mvIMPACT_acquire.h:4136
The function interface to devices supported by this interface.
Definition: mvIMPACT_acquire.h:10443
int imageRequestWaitFor(int timeout_ms, int queueNr=0) const
Waits for a request object to become ready.
Definition: mvIMPACT_acquire.h:11335
int imageRequestUnlock(int nr) const
Unlocks the request for the driver again.
Definition: mvIMPACT_acquire.h:11303
int imageRequestSingle(ImageRequestControl *pImageRequestControl=0, int *pRequestUsed=0) const
Sends an image request to the mvIMPACT::acquire::Device driver.
Definition: mvIMPACT_acquire.h:11222
bool isRequestNrValid(int nr) const
Check if nr specifies a valid mvIMPACT::acquire::Request.
Definition: mvIMPACT_acquire.h:11470
int imageRequestReset(int requestCtrlNr, int mode) const
Deletes all requests currently queued for the specified mvIMPACT::acquire::ImageRequestControl.
Definition: mvIMPACT_acquire.h:11169
Request * getRequest(int nr) const
Returns a pointer to the desired mvIMPACT::acquire::Request.
Definition: mvIMPACT_acquire.h:10908
A base class for exceptions generated by mvIMPACT Acquire.
Definition: mvIMPACT_acquire.h:248
int getErrorCode(void) const
Returns a unique numerical representation for this error.
Definition: mvIMPACT_acquire.h:267
A base class for properties.
Definition: mvIMPACT_acquire.h:3007
std::string readS(int index=0, const std::string &format="") const
Reads data from this property as a string.
Definition: mvIMPACT_acquire.h:3213
Contains information about a captured buffer.
Definition: mvIMPACT_acquire.h:8408
PropertyI imageHeight
An integer property (read-only) containing the height of the image in pixels.
Definition: mvIMPACT_acquire.h:10020
bool isOK(void) const
Convenience function to check if a request has been processed successfully.
Definition: mvIMPACT_acquire.h:9197
PropertyIRequestResult requestResult
An enumerated integer property (read-only) defining the result of this request.
Definition: mvIMPACT_acquire.h:9500
PropertyI imageWidth
An integer property (read-only) containing the width of the image in pixels.
Definition: mvIMPACT_acquire.h:10009
A class that can be used to display images in a window.
Definition: mvIMPACT_acquire_display.h:582
ImageDisplay & GetImageDisplay(void)
Returns a reference to the actual display object associated with this window.
Definition: mvIMPACT_acquire_display.h:609
void SetImage(const void *pData, int width, int height, int bitsPerPixel, int pitch)
Sets the next image to display.
Definition: mvIMPACT_acquire_display.h:292
void Update(void) const
Immediately redraws the current image.
Definition: mvIMPACT_acquire_display.h:381
This namespace contains classes and functions that can be used to display images.
This namespace contains classes and functions belonging to the image acquisition module of this SDK.
Definition: mvImageBuffer.h:42