bool configureDevice( Device* pDev )
{
ImageFormatControl ifc( pDev );
if( ifc.componentSelector.isValid() && ifc.componentSelector.isWriteable() )
{
if( !supportsEnumStringValue( ifc.componentSelector, "Confidence" ) )
{
return false;
}
ifc.componentSelector.writeS( "Confidence" );
ifc.componentEnable.write( TBoolean::bTrue );
if( !supportsEnumStringValue( ifc.componentSelector, "Disparity" ) )
{
return false;
}
ifc.componentSelector.writeS( "Disparity" );
ifc.componentEnable.write( TBoolean::bFalse );
}
else
{
return false;
}
AcquisitionControl acq( pDev );
if( !acq.exposureAuto.isValid() ||
!acq.exposureAuto.isWriteable() ||
!acq.acquisitionMultiPartMode.isValid() ||
!acq.acquisitionMultiPartMode.isWriteable() )
{
return false;
}
if( !supportsEnumStringValue( acq.exposureAuto, "Continuous" ) ||
!supportsEnumStringValue( acq.acquisitionMultiPartMode, "SynchronizedComponents" ) )
{
return false;
}
acq.exposureAuto.writeS( "Continuous" );
acq.acquisitionMultiPartMode.writeS( "SynchronizedComponents" );
ChunkDataControl cdc( pDev );
if( !cdc.chunkModeActive.isValid() || !cdc.chunkModeActive.isWriteable() )
{
return false;
}
cdc.chunkModeActive.write( TBoolean::bTrue );
DepthControl dctl( pDev );
if( !dctl.depthAcquisitionMode.isValid() ||
!dctl.depthAcquisitionMode.isWriteable() ||
!dctl.depthExposureAdaptTimeout.isValid() ||
!dctl.depthExposureAdaptTimeout.isWriteable() ||
!dctl.depthQuality.isValid() ||
!dctl.depthQuality.isWriteable() )
{
return false;
}
if( !supportsEnumStringValue( dctl.depthAcquisitionMode, "Continuous" ) ||
!supportsEnumStringValue( dctl.depthQuality, "High" ) ||
!supportsValue( dctl.depthExposureAdaptTimeout, 0.0 ) )
{
return false;
}
dctl.depthAcquisitionMode.writeS( "Continuous" );
dctl.depthExposureAdaptTimeout.write( 0.0 );
dctl.depthQuality.writeS( "High" );
return true;
}
void myThreadCallback( shared_ptr<Request> pRequest, ThreadParameter& threadParameter )
{
if( threadParameter.requestsCaptured_ % 100 == 0 )
{
const Statistics& s = threadParameter.statistics_;
cout << "Info from " << threadParameter.pDev_->serial.read()
<< ": " << s.framesPerSecond.name() << ": " << s.framesPerSecond.readS()
<< ", " << s.errorCount.name() << ": " << s.errorCount.readS()
<< ", " << s.captureTime_s.name() << ": " << s.captureTime_s.readS() << endl;
}
if( pRequest->isOK() )
{
const unsigned int bufferPartCount = pRequest->getBufferPartCount();
if( bufferPartCount > 0 )
{
for( unsigned int i = 0; i < bufferPartCount; i++ )
{
const BufferPart& bufferPart( pRequest->getBufferPart( i ) );
const string pixelFormat = bufferPart.pixelFormat.readS();
#ifdef USE_DISPLAY
const TBufferPartDataType bufferDataType = bufferPart.dataType.read();
const int linePitch = static_cast<int>( bufferPart.linePitch.read() );
const int width = static_cast<int>( bufferPart.width.read() );
const int height = static_cast<int>( bufferPart.height.read() );
const int channelbBitDepth = static_cast<int>( bufferPart.channelBitDepth.read() );
cout << "Image captured: " << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << "buffer contains: " << bufferDataType << " data" << endl;
if( bufferDataType == bpdt2DImage )
{
threadParameter.displayWindowPrimary_.GetImageDisplay().SetImage( bufferPart.address.read(), width, height, channelbBitDepth, linePitch );
threadParameter.displayWindowPrimary_.GetImageDisplay().Update();
}
else if( bufferDataType == bpdtConfidenceMap )
{
threadParameter.displayWindowSecondary_.GetImageDisplay().SetImage( bufferPart.address.read(), width, height, channelbBitDepth, linePitch );
threadParameter.displayWindowSecondary_.GetImageDisplay().Update();
}
else
{
cout << "The data type of buffer part " << i << " of the current request is reported as " << bufferPart.dataType.readS() << ", which will NOT be handled by this example application" << endl;
}
#else
cout << "Image captured: " << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << "buffer contains: " << bufferPart.dataType.readS() << " data" << endl;
#endif
}
}
}
else
{
cout << "Error: " << pRequest->requestResult.readS() << endl;
}
}
#include <apps/Common/exampleHelper.h>
#include <common/crt/mvstdio.h>
#include <iostream>
#include <mvIMPACT_CPP/mvIMPACT_acquire_helper.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire_GenICam.h>
#ifdef _WIN32
# include <mvDisplay/Include/mvIMPACT_acquire_display.h>
# define USE_DISPLAY
#endif
using namespace std;
struct ThreadParameter
{
unsigned int requestsCaptured_;
#ifdef USE_DISPLAY
#endif
explicit ThreadParameter(
Device* pDev ) : pDev_( pDev ), requestsCaptured_( 0 ), statistics_( pDev )
#ifdef USE_DISPLAY
, displayWindowPrimary_(
"mvIMPACT_acquire sample, Device " + pDev_->
serial.
read() +
" 2D Image" )
, displayWindowSecondary_(
"mvIMPACT_acquire sample, Device " + pDev_->
serial.
read() +
" 3D Data" )
#endif
{}
ThreadParameter( const ThreadParameter& src ) = delete;
ThreadParameter& operator=( const ThreadParameter& rhs ) = delete;
};
void myThreadCallback( shared_ptr<Request> pRequest, ThreadParameter& threadParameter )
{
if( threadParameter.requestsCaptured_ % 100 == 0 )
{
const Statistics& s = threadParameter.statistics_;
cout << "Info from " << threadParameter.pDev_->serial.read()
}
if( pRequest->isOK() )
{
const unsigned int bufferPartCount = pRequest->getBufferPartCount();
if( bufferPartCount > 0 )
{
for( unsigned int i = 0; i < bufferPartCount; i++ )
{
const BufferPart& bufferPart( pRequest->getBufferPart( i ) );
const string pixelFormat = bufferPart.pixelFormat.readS();
#ifdef USE_DISPLAY
const int linePitch = static_cast<int>( bufferPart.linePitch.read() );
const int width = static_cast<int>( bufferPart.width.read() );
const int height = static_cast<int>( bufferPart.height.read() );
const int channelbBitDepth = static_cast<int>( bufferPart.channelBitDepth.read() );
cout << "Image captured: " << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << "buffer contains: " << bufferDataType << " data" << endl;
if( bufferDataType == bpdt2DImage )
{
threadParameter.displayWindowPrimary_.GetImageDisplay().SetImage( bufferPart.address.read(), width, height, channelbBitDepth, linePitch );
threadParameter.displayWindowPrimary_.GetImageDisplay().Update();
}
else if( bufferDataType == bpdtConfidenceMap )
{
threadParameter.displayWindowSecondary_.GetImageDisplay().SetImage( bufferPart.address.read(), width, height, channelbBitDepth, linePitch );
threadParameter.displayWindowSecondary_.GetImageDisplay().Update();
}
else
{
cout << "The data type of buffer part " << i << " of the current request is reported as " << bufferPart.dataType.readS() << ", which will NOT be handled by this example application" << endl;
}
#else
cout << "Image captured: " << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << "buffer contains: " << bufferPart.dataType.readS() << " data" << endl;
#endif
}
}
}
else
{
cout << "Error: " << pRequest->requestResult.readS() << endl;
}
}
bool isDeviceSupportedBySample(
const Device*
const pDev )
{
return ( product.find( "rc_visard" ) != std::string::npos );
}
bool configureDevice(
Device* pDev )
{
if( ifc.componentSelector.isValid() && ifc.componentSelector.isWriteable() )
{
if( !supportsEnumStringValue( ifc.componentSelector, "Confidence" ) )
{
return false;
}
ifc.componentSelector.writeS( "Confidence" );
ifc.componentEnable.write( TBoolean::bTrue );
if( !supportsEnumStringValue( ifc.componentSelector, "Disparity" ) )
{
return false;
}
ifc.componentSelector.writeS( "Disparity" );
ifc.componentEnable.write( TBoolean::bFalse );
}
else
{
return false;
}
if( !acq.exposureAuto.isValid() ||
!acq.exposureAuto.isWriteable() ||
!acq.acquisitionMultiPartMode.isValid() ||
!acq.acquisitionMultiPartMode.isWriteable() )
{
return false;
}
if( !supportsEnumStringValue( acq.exposureAuto, "Continuous" ) ||
!supportsEnumStringValue( acq.acquisitionMultiPartMode, "SynchronizedComponents" ) )
{
return false;
}
acq.exposureAuto.writeS( "Continuous" );
acq.acquisitionMultiPartMode.writeS( "SynchronizedComponents" );
if( !cdc.chunkModeActive.isValid() || !cdc.chunkModeActive.isWriteable() )
{
return false;
}
cdc.chunkModeActive.write( TBoolean::bTrue );
if( !dctl.depthAcquisitionMode.isValid() ||
!dctl.depthAcquisitionMode.isWriteable() ||
!dctl.depthExposureAdaptTimeout.isValid() ||
!dctl.depthExposureAdaptTimeout.isWriteable() ||
!dctl.depthQuality.isValid() ||
!dctl.depthQuality.isWriteable() )
{
return false;
}
if( !supportsEnumStringValue( dctl.depthAcquisitionMode, "Continuous" ) ||
!supportsEnumStringValue( dctl.depthQuality, "High" ) ||
!supportsValue( dctl.depthExposureAdaptTimeout, 0.0 ) )
{
return false;
}
dctl.depthAcquisitionMode.writeS( "Continuous" );
dctl.depthExposureAdaptTimeout.write( 0.0 );
dctl.depthQuality.writeS( "High" );
return true;
}
int main( void )
{
Device* pDev = getDeviceFromUserInput( devMgr, isDeviceSupportedBySample );
if( pDev == nullptr )
{
cout << "Unable to continue! Press [ENTER] to end the application" << endl;
cin.get();
return 1;
}
{
}
else
{
cout << "Unable to continue! The selected device could not be opnened. Press [ENTER] to end the application" << endl;
cin.get();
return 1;
}
cout << "Initialising the device. This might take some time..." << endl;
if( !configureDevice( pDev ) )
{
cout << "Unable to continue! The selected device does not support some of the required features. Press [ENTER] to end the application" << endl;
cin.get();
return 1;
}
ThreadParameter threadParam( pDev );
cout << "Press [ENTER] to stop the acquisition thread" << endl;
requestProvider.acquisitionStart( myThreadCallback, std::ref( threadParam ) );
cin.get();
requestProvider.acquisitionStop();
return 0;
}
Contains information about a specific part of a captured buffer.
Definition mvIMPACT_acquire.h:8410
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 product
A string property (read-only) containing the product name of this device.
Definition mvIMPACT_acquire.h:6537
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
PropertyIDeviceInterfaceLayout interfaceLayout
An enumerated integer property which can be used to define which interface layout shall be used when ...
Definition mvIMPACT_acquire.h:6644
bool isOpen(void) const
Returns the current initialisation status in this process.
Definition mvIMPACT_acquire.h:6363
PropertyIAcquisitionStartStopBehaviour acquisitionStartStopBehaviour
An enumerated integer property defining the start/stop behaviour during acquisition of this driver in...
Definition mvIMPACT_acquire.h:6800
Category for the acquisition and trigger control features.
Definition mvIMPACT_acquire_GenICam.h:2115
Category that contains the Chunk Data control features.
Definition mvIMPACT_acquire_GenICam.h:11823
Adjustment and triggering of the depth image for 3D control.
Definition mvIMPACT_acquire_GenICam.h:11048
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:14509
PropertyF framesPerSecond
A float property (read-only) containing the current number of frames captured per second.
Definition mvIMPACT_acquire.h:14586
PropertyF captureTime_s
A float property (read-only) containing the overall time an image request spent in the device drivers...
Definition mvIMPACT_acquire.h:14560
PropertyI errorCount
An integer property (read-only) containing the overall count of image requests which returned with an...
Definition mvIMPACT_acquire.h:14568
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
TBufferPartDataType
Defines buffer part data types.
Definition TBufferPartDataType.h:41
This namespace contains classes and functions belonging to the GenICam specific part of the image acq...
Definition mvIMPACT_acquire.h:23830
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