The continuous acquisition is similar to the single capture. The only major difference is, that this sample continuously requests images from the device.
After the last pixel format the application stops after a last click on any key.
All pixel formats that are supported by Impact Acquire will be processed and displayed. To find out which pixel formats are supported refer to mvIMPACT::acquire::TImageBufferPixelFormat.
#include <functional>
#include <iostream>
#include <apps/Common/exampleHelper.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire_helper.h>
#include <mvDisplay/Include/mvIMPACT_acquire_display.h>
using namespace std;
struct ThreadParameter
{
unsigned int requestsCaptured_;
explicit ThreadParameter(
Device* pDev,
const string& windowTitle ) : pDev_( pDev ), requestsCaptured_( 0 ), statistics_( pDev ), dispRaw_( windowTitle ), dispConverted_( windowTitle +
"(converted)" ) {}
ThreadParameter( const ThreadParameter& src ) = delete;
ThreadParameter& operator=( const ThreadParameter& rhs ) = delete;
};
void myThreadCallback( shared_ptr<Request> pRequest, ThreadParameter& threadParameter )
{
++threadParameter.requestsCaptured_;
if( threadParameter.requestsCaptured_ % 100 == 0 )
{
const Statistics& s = threadParameter.statistics_;
cout << "Info from " << threadParameter.pDev_->serial.read()
}
if( pRequest->isOK() )
{
threadParameter.dispRaw_.GetImageDisplay().SetImage( pRequest->imageData.read(), pRequest->imageWidth.read(), pRequest->imageHeight.read(), pRequest->imagePixelPitch.read() * 8, pRequest->imageLinePitch.read() );
threadParameter.dispRaw_.GetImageDisplay().Update();
threadParameter.dispConverted_.GetImageDisplay().SetImage( pRequest );
threadParameter.dispConverted_.GetImageDisplay().Update();
}
else
{
cout << "Error: " << pRequest->requestResult.readS() << endl;
}
}
int main( void )
{
Device* pDev = getDeviceFromUserInput( devMgr );
if( pDev == nullptr )
{
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;
cout << "The following formats are available:" << endl;
DisplayPropertyDictionary<PropertyIImageDestinationPixelFormat>( id.pixelFormat );
vector<pair<string, TImageDestinationPixelFormat>> validDestinationPixelFormats;
id.pixelFormat.getTranslationDict( validDestinationPixelFormats );
for( const auto validDestinationPixelFormat : validDestinationPixelFormats )
{
id.pixelFormat.write( validDestinationPixelFormat.second );
const string windowTitle(
"Device " + pDev->
serial.
read() +
"(pixel format " + validDestinationPixelFormat.first +
")" );
cout << "Currently using " << validDestinationPixelFormat.first << ". Press [ENTER] to switch to the next format" << endl;
ThreadParameter threadParam( pDev, windowTitle );
requestProvider.acquisitionStart( myThreadCallback, std::ref( threadParam ) );
cin.get();
requestProvider.acquisitionStop();
}
cout << "Press [ENTER] to end the application" << endl;
cin.get();
return 0;
}
std::string name(void) const
Returns the name of the component referenced by this object.
Definition mvIMPACT_acquire.h:1206
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:3853
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
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 basic statistical information.
Definition mvIMPACT_acquire.h:14517
PropertyF framesPerSecond
A float property (read-only) containing the current number of frames captured per second.
Definition mvIMPACT_acquire.h:14594
PropertyF bandwidthConsumed
A float property (read-only) containing the current bandwidth consumed by this device in KB/s based o...
Definition mvIMPACT_acquire.h:14573
PropertyF captureTime_s
A float property (read-only) containing the overall time an image request spent in the device drivers...
Definition mvIMPACT_acquire.h:14568
PropertyI errorCount
An integer property (read-only) containing the overall count of image requests which returned with an...
Definition mvIMPACT_acquire.h:14576
A class that can be used to display images in a window.
Definition mvIMPACT_acquire_display.h:606
A helper class that can be used to implement a simple continuous acquisition from a device.
Definition mvIMPACT_acquire_helper.h:432
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