#ifdef _MSC_VER
# if _MSC_VER < 1300
# pragma warning( disable : 4786 )
# endif
#endif
#include <windows.h>
#include <process.h>
#include <iostream>
#include <apps/Common/exampleHelper.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#include <mvDisplay/Include/mvIMPACT_acquire_display.h>
using namespace std;
static bool s_boTerminated = false;
struct ThreadParameter
{
ThreadParameter(
Device* p,
const string& windowTitle ) : pDev( p ), dispRaw( windowTitle ), dispConverted( windowTitle +
"(converted)" ) {}
};
unsigned int __stdcall liveThread( void* pData )
{
ThreadParameter* pThreadParameter = reinterpret_cast<ThreadParameter*>( pData );
unsigned int cnt = 0;
{
cout << "'FunctionInterface.imageRequestSingle' returned with an unexpected result: " << result
}
manuallyStartAcquisitionIfNeeded( pThreadParameter->pDev, fi );
const unsigned int timeout_ms = 500;
while( !s_boTerminated )
{
requestNr = fi.imageRequestWaitFor( timeout_ms );
if( fi.isRequestNrValid( requestNr ) )
{
pRequest = fi.getRequest( requestNr );
{
++cnt;
if( cnt % 100 == 0 )
{
cout << "Info from " << pThreadParameter->pDev->serial.read()
<< ": " << statistics.framesPerSecond.name() << ": " << statistics.framesPerSecond.readS()
<< ", " << statistics.errorCount.name() << ": " << statistics.errorCount.readS()
<< ", " << statistics.captureTime_s.name() << ": " << statistics.captureTime_s.readS()
}
pThreadParameter->dispRaw.GetImageDisplay().Update();
pThreadParameter->dispConverted.GetImageDisplay().SetImage( pRequest );
pThreadParameter->dispConverted.GetImageDisplay().Update();
}
else
{
}
if( fi.isRequestNrValid( lastRequestNr ) )
{
fi.imageRequestUnlock( lastRequestNr );
}
lastRequestNr = requestNr;
fi.imageRequestSingle();
}
}
manuallyStopAcquisitionIfNeeded( pThreadParameter->pDev, fi );
pThreadParameter->dispRaw.GetImageDisplay().RemoveImage();
pThreadParameter->dispConverted.GetImageDisplay().RemoveImage();
if( fi.isRequestNrValid( requestNr ) )
{
fi.imageRequestUnlock( requestNr );
}
fi.imageRequestReset( 0, 0 );
return 0;
}
int main( void )
{
Device* pDev = getDeviceFromUserInput( devMgr );
if( !pDev )
{
cout << "Unable to continue! Press [ENTER] to end the application" << endl;
cin.get();
return 1;
}
cout << "Initialising the device. This might take some time..." << endl;
try
{
}
{
cout <<
"An error occurred while opening device " << pDev->
serial.
read()
<< "Press [ENTER] to end the application..." << endl;
cin.get();
return 1;
}
cout << "Please note that only the window displaying the converted image will display correct" << endl
<< "images all the time. The other window will simply blit the raw image data in the client" << endl
<< "area. This is faster but e.g. for 12 bit mono data or YUV data will result in unexpected" << endl
<< "results. For planar formats e.g. just the first plane might be visible." << endl
<< "For certain other formats the unconverted window might even blit no data at all." << endl
<< "This e.g. will be the case for 10-16 bit RGB packed data." << endl;
unsigned int pixelFormats = id.pixelFormat.dictSize();
cout << "The following formats are available:" << endl;
for( unsigned int i = 0; i < pixelFormats; i++ )
{
cout << "[" << id.pixelFormat.getTranslationDictValue( i ) << "]: " << id.pixelFormat.getTranslationDictString( i ) << endl;
}
for( unsigned int j = 0; j < pixelFormats; j++ )
{
s_boTerminated = false;
id.pixelFormat.write( id.pixelFormat.getTranslationDictValue( j ) );
const string windowTitle(
"Device " + pDev->
serial.
read() +
"(pixel format " +
id.pixelFormat.getTranslationDictString( j ) +
")" );
cout << "Currently using " << id.pixelFormat.getTranslationDictString( j ) << ". Press [ENTER] to switch to the next format" << endl;
unsigned int dwThreadID;
ThreadParameter threadParam( pDev, windowTitle );
HANDLE hThread = ( HANDLE )_beginthreadex( 0, 0, liveThread, ( LPVOID )( &threadParam ), 0, &dwThreadID );
cin.get();
s_boTerminated = true;
WaitForSingleObject( hThread, INFINITE );
CloseHandle( hThread );
}
cout << "Press [ENTER] to end the application" << endl;
cin.get();
return 0;
}
Grants access to devices that can be operated by this software interface.
Definition mvIMPACT_acquire.h:7171
This class and its functions represent an actual device detected by this interface in the current sys...
Definition mvIMPACT_acquire.h:6118
PropertyS serial
A string property (read-only) containing the serial number of this device.
Definition mvIMPACT_acquire.h:6551
void open(void)
Opens a device.
Definition mvIMPACT_acquire.h:6420
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
Properties to define the format of resulting images.
Definition mvIMPACT_acquire.h:12377
A base class for exceptions generated by Impact Acquire.
Definition mvIMPACT_acquire.h:256
std::string getErrorCodeAsString(void) const
Returns a string representation of the error associated with the exception.
Definition mvIMPACT_acquire.h:288
void * read(int index=0) const
Reads a value from a property.
Definition mvIMPACT_acquire.h:5176
std::string read(int index=0) const
Reads a value from a property.
Definition mvIMPACT_acquire.h:5323
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
PropertyI imagePixelPitch
An integer property (read-only) containing the offset (in bytes) to the next pixel of the specified c...
Definition mvIMPACT_acquire.h:10225
PropertyI imageHeight
An integer property (read-only) containing the height of the image in pixels.
Definition mvIMPACT_acquire.h:10331
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
PropertyPtr imageData
A pointer property (read-only) containing the start address of the image data.
Definition mvIMPACT_acquire.h:10187
PropertyI imageLinePitch
An integer property (read-only) containing the offset (in bytes) to the next line of each channel bel...
Definition mvIMPACT_acquire.h:10262
Contains basic statistical information.
Definition mvIMPACT_acquire.h:14517
A class that can be used to display images in a window.
Definition mvIMPACT_acquire_display.h:606
TDMR_ERROR
Errors reported by the device manager.
Definition mvDriverBaseEnums.h:2601
const int INVALID_ID
A constant to check for an invalid ID returned from the property handling module.
Definition mvPropHandlingDatatypes.h:64
@ DEV_NO_FREE_REQUEST_AVAILABLE
The user requested a new image, but no free mvIMPACT::acquire::Request object is available to process...
Definition mvDriverBaseEnums.h:2713
@ DMR_NO_ERROR
The function call was executed successfully.
Definition mvDriverBaseEnums.h:2603
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 mvCommonDataTypes.h:34