//----------------------------------------------------------------------------- int main( int argc, char* argv[]) //----------------------------------------------------------------------------- { const char* pDevSerial = "BF*"; cout << "\n ++ Start PowerDownTest sample: " << __DATE__ << "/" << __TIME__ << endl; if( argc > 1 ) { pDevSerial = argv[1]; } unsigned int uiDevCount = 0; DeviceManager DevMgr; if( ( uiDevCount = DevMgr.deviceCount() ) == 0 ) { cout << "*** Error: No MATRIX VISION device found! Unable to continue!" << endl; return 0; } cout << "Have found " << uiDevCount << " devices on this platform!" << endl; for( unsigned i=0; i<uiDevCount; i++ ) { Device* pDevTmp = DevMgr.getDevice( i ); cout << " " << i << " Serial: " << pDevTmp->serial.read() << endl; } cout << "Initialising the device: "<< pDevSerial << ". This might take some time..." << endl; // create an interface to the first MATRIX VISION device with the serila number pDevSerial Device* pDev = DevMgr.getDeviceBySerial( pDevSerial ); try { pDev->open(); } catch( ImpactAcquireException& e ) { // this e.g. might happen if the same device is already opened in another process... cout << "*** Error: An error occurred while opening the device(error code: " << e.getErrorCode() << ")." << endl; return 0; } FunctionInterface fi( pDev ); // only 8Bit/pixel destination image are supported by the \c writeFile() function ImageDestination imgDst( pDev ); imgDst.pixelFormat.write( idpfMono8 ); // get mvBF system settings SystemBlueFOX sbf( pDev ); bool bPowerDown = false; do { cout << "Ready to snap. Press 'p'<return> to power down, 'q'<return> to quit or <return> to snap an image.." << endl; char ch = getchar(); if( ch == 'p' ) { // for mvBlueFOX only: test power down / up cout << "Power off!" << endl; sbf.powerMode.write( dpmOff ); bPowerDown = true; // read and discard the <return> getchar(); } else if( ch == 'q' ) { // break out of loop to finish application // read and discard the <return> getchar(); break; } else { // snap if( bPowerDown ) { // first we need to power up again CTime timer1; sbf.powerMode.write( dpmOn ); bPowerDown = false; cout << "Power On!" << ". Power On took " << timer1.elapsed() << "s., " << endl; } CTime timer; // send a request to the default request queue of the device and wait for the result. fi.imageRequestSingle(); const int iMaxWaitTime_ms = 5000; // wait for results from the default capture queue int iRequestNr = fi.imageRequestWaitFor( iMaxWaitTime_ms ); cout << "Request Nr.: " << iRequestNr << ". Snap took " << timer.elapsed() << "s., " << endl; // check if the image has been captured without any problems if( !fi.isRequestNrValid( iRequestNr ) ) { // this can not happen in this sample, but may happen if you wait for a request without // sending one to the driver before cout << "*** Error: No request has been sent to the driver." << endl; // unlock the buffer to let the driver know that you no longer need this buffer fi.imageRequestUnlock( iRequestNr ); // free resources fi.imageRequestReset( 0, 0 ); pDev->close(); return 0; } const Request* psRequest = fi.getRequest(iRequestNr); if( !fi.isRequestOK( psRequest ) ) { cout << "*** " << psRequest->requestResult << endl; // unlock the buffer to let the driver know that you no longer need this buffer fi.imageRequestUnlock( iRequestNr ); // free resources fi.imageRequestReset( 0, 0 ); pDev->close(); return 0; } // Everything went well. Save the result const char* pImageName = "SingCapt.pgm"; cout << "Will save the file as: " << pImageName << endl; if( writeFile( (const unsigned char*)psRequest->imageData.read(), psRequest->imageWidth.read(), psRequest->imageHeight.read(), psRequest->imageLinePitch.read(), psRequest->imagePixelPitch.read(), pImageName ) < 0 ) cout << "*** Error: File: "<< pImageName << " could not be saved!!" << endl; // unlock the buffer to let the driver know that you no longer need this buffer fi.imageRequestUnlock( iRequestNr ); } // snap } while( true ); // free resources fi.imageRequestReset( 0, 0 ); pDev->close(); return 0; }
//----------------------------------------------------------------------------- int main( int argc, char* argv[]) //----------------------------------------------------------------------------- { if( argc > 2 ) { cout << "Invalid input parameter count" << endl << endl; printHelp(); return 0; } unsigned int devCnt = 0; DeviceManager devMgr; if(( devCnt = devMgr.deviceCount()) == 0 ) { cout << "*** Error: No MATRIX VISION device found! Unable to continue!" << endl; return 0; } cout << "Have found " << devCnt << " devices on this platform!" << endl << "Please note that this application will only work for mvBlueFOX devices" <<endl; if( argc == 1 ) { int index = 0; Device* pDev = 0; while( ( pDev = devMgr.getDeviceByFamily( "mvBlueFOX", index ) ) != 0 ) { updateFirmware( pDev ); ++index; } } else { string command(argv[1]); if( command == "-sel" ) { Device* pDev = getDeviceFromUserInput( devMgr ); if( !pDev ) { return 0; } updateFirmware( pDev ); } else if( command.find( "-d" ) == 0 ) { string serial(command.substr( 2 )); Device* pDev = devMgr.getDeviceBySerial( serial ); if( !pDev ) { cout << "Can't find Device " << serial << endl; return 0; } updateFirmware( pDev ); } else if( command == "-help" ) { printHelp(); } else { cout << "Invalid input parameter: " << command << endl << endl; printHelp(); return 0; } } return 0; }
//----------------------------------------------------------------------------- int main( int argc, char* argv[] ) //----------------------------------------------------------------------------- { #ifdef MALLOC_TRACE mtrace(); #endif // MALLOC_TRACE cout << " ++ starting application...." << endl; bool boStoreFrames = false; string settingName; int width = -1; int height = -1; string pixelFormat; string acquisitionMode; string deviceSerial; int defaultRequestCount = -1; for( int i = 1; i < argc; i++ ) { string arg( argv[i] ); if( string( argv[i] ) == "-sf" ) { boStoreFrames = true; } else if( arg.find( "-a" ) == 0 ) { acquisitionMode = arg.substr( 2 ); } else if( arg.find( "-drc" ) == 0 ) { defaultRequestCount = atoi( arg.substr( 4 ).c_str() ); } else if( arg.find( "-h" ) == 0 ) { height = atoi( arg.substr( 2 ).c_str() ); } else if( arg.find( "-s" ) == 0 ) { deviceSerial = arg.substr( 2 ); } else if( arg.find( "-w" ) == 0 ) { width = atoi( arg.substr( 2 ).c_str() ); } else { // try to load this setting later on... settingName = string( argv[1] ); } } if( argc <= 1 ) { cout << "Available command line parameters:" << endl << endl << "-sf to store every 100th frame in raw format" << endl << "-a<mode> to set the acquisition mode" << endl << "-h<height> to set the AOI width" << endl << "-s<serialNumber> to pre-select a certain device. If this device can be found no further user interaction is needed" << endl << "-w<width> to set the AOI width" << endl << "-drc<bufferCount> to specify the default request count" << endl << "any other string will be interpreted as a name of a setting to load" << endl; } DeviceManager devMgr; Device* pDev = 0; if( !deviceSerial.empty() ) { pDev = devMgr.getDeviceBySerial( deviceSerial ); if( pDev ) { // if this device offers the 'GenICam' interface switch it on, as this will // allow are better control over GenICam compliant devices conditionalSetProperty( pDev->interfaceLayout, dilGenICam ); // if this device offers a user defined acquisition start/stop behaviour // enable it as this allows finer control about the streaming behaviour conditionalSetProperty( pDev->acquisitionStartStopBehaviour, assbUser ); } } if( !pDev ) { // this will automatically set the interface layout etc. to the values from the branch above pDev = getDeviceFromUserInput( devMgr ); } if( pDev == 0 ) { cout << "Unable to continue!"; PRESS_A_KEY_AND_RETURN }
//----------------------------------------------------------------------------- int main( int argc, char* argv[] ) //----------------------------------------------------------------------------- { #ifdef MALLOC_TRACE mtrace(); #endif // MALLOC_TRACE cout << " ++ starting application...." << endl; string settingName; int width = -1; int height = -1; string pixelFormat; string acquisitionMode; string deviceSerial; int defaultRequestCount = -1; for( int i = 1; i < argc; i++ ) { string arg( argv[i] ); if( arg.find( "-a" ) == 0 ) { acquisitionMode = arg.substr( 2 ); } else if( arg.find( "-drc" ) == 0 ) { defaultRequestCount = atoi( arg.substr( 4 ).c_str() ); } else if( arg.find( "-h" ) == 0 ) { height = atoi( arg.substr( 2 ).c_str() ); } else if( arg.find( "-p" ) == 0 ) { pixelFormat = arg.substr( 2 ); } else if( arg.find( "-s" ) == 0 ) { deviceSerial = arg.substr( 2 ); } else if( arg.find( "-w" ) == 0 ) { width = atoi( arg.substr( 2 ).c_str() ); } else { // try to load this setting later on... settingName = string( argv[1] ); } } if( argc <= 1 ) { cout << "Available command line parameters:" << endl << endl << "-sf to store every 100th frame in raw format" << endl << "-a<mode> to set the acquisition mode" << endl << "-h<height> to set the AOI width" << endl << "-p<pixelFormat> to set the pixel format" << endl << "-s<serialNumber> to pre-select a certain device. If this device can be found no further user interaction is needed" << endl << "-w<width> to set the AOI width" << endl << "-drc<bufferCount> to specify the default request count" << endl << "any other string will be interpreted as a name of a setting to load" << endl; } DeviceManager devMgr; Device* pDev = 0; bool bGoOn( true ); while( bGoOn ) { if( !deviceSerial.empty() ) { pDev = devMgr.getDeviceBySerial( deviceSerial ); if( pDev ) { // if this device offers the 'GenICam' interface switch it on, as this will // allow are better control over GenICam compliant devices conditionalSetProperty( pDev->interfaceLayout, dilGenICam ); // if this device offers a user defined acquisition start/stop behaviour // enable it as this allows finer control about the streaming behaviour conditionalSetProperty( pDev->acquisitionStartStopBehaviour, assbUser ); } } if( !pDev ) { // this will automatically set the interface layout etc. to the values from the branch above pDev = getDeviceFromUserInput( devMgr ); } if( pDev ) { deviceSerial = pDev->serial.read(); cout << "Initialising device: " << pDev->serial.read() << ". This might take some time..." << endl << "Using interface layout '" << pDev->interfaceLayout.readS() << "'." << endl; try { if( defaultRequestCount > 0 ) { cout << "Setting default request count to " << defaultRequestCount << endl; pDev->defaultRequestCount.write( defaultRequestCount ); } pDev->open(); switch( pDev->interfaceLayout.read() ) { case dilGenICam: { mvIMPACT::acquire::GenICam::ImageFormatControl ifc( pDev ); mvIMPACT::acquire::GenICam::AcquisitionControl ac( pDev ); if( width > 0 ) { ifc.width.write( width ); } if( height > 0 ) { ifc.height.write( height ); } if( !pixelFormat.empty() ) { ifc.pixelFormat.writeS( pixelFormat ); } if( !acquisitionMode.empty() ) { ac.acquisitionMode.writeS( acquisitionMode ); } acquisitionMode = ac.acquisitionMode.readS(); cout << "Device set up to " << ifc.pixelFormat.readS() << " " << ifc.width.read() << "x" << ifc.height.read() << endl; } break; case dilDeviceSpecific: { CameraSettingsBase cs( pDev ); if( width > 0 ) { cs.aoiWidth.write( width ); } if( height > 0 ) { cs.aoiHeight.write( height ); } cout << "Device set up to " << cs.aoiWidth.read() << "x" << cs.aoiHeight.read() << endl; } break; default: break; } // start the execution of the 'live' loop. cout << "starting live loop" << endl; if( liveLoop( pDev, settingName, acquisitionMode == "SingleFrame" ) == false ) // stop for user input { bGoOn = false; } cout << "finished live loop" << endl; pDev->close(); } catch( const ImpactAcquireException& e ) { // this e.g. might happen if the same device is already opened in another process... cout << "*** " << __FUNCTION__ << " - An error occurred while opening the device " << pDev->serial.read() << "(error code: " << e.getErrorCode() << ", " << e.getErrorCodeAsString() << "). Press any key to end the application..." << endl; } } else { cout << "Unable to get device!"; break; } if( waitForInput( 0, STDOUT_FILENO ) != 0 ) { break; } } cout << " -- ending application...." << endl; return 0; }
//----------------------------------------------------------------------------- int main( int argc, char* argv[] ) //----------------------------------------------------------------------------- { #ifdef MALLOC_TRACE mtrace(); #endif // MALLOC_TRACE cout << " ++ starting application...." << endl; bool boStoreFrames = false; string settingName; int width = -1; int height = -1; string pixelFormat; string acquisitionMode; string deviceSerial; for( int i=1; i<argc; i++ ) { string arg(argv[i]); if( string( argv[i] ) == "-sf" ) { boStoreFrames = true; } else if( arg.find( "-a" ) == 0 ) { acquisitionMode = arg.substr( 2 ); } else if( arg.find( "-h" ) == 0 ) { height = atoi( arg.substr( 2 ).c_str() ); } else if( arg.find( "-p" ) == 0 ) { pixelFormat = arg.substr( 2 ); } else if( arg.find( "-s" ) == 0 ) { deviceSerial = arg.substr( 2 ); } else if( arg.find( "-w" ) == 0 ) { width = atoi( arg.substr( 2 ).c_str() ); } else { // try to load this setting later on... settingName = string(argv[1]); } } if( argc <= 1 ) { cout << "Available command line parameters:" << endl << endl << "-sf to store every 100th frame in raw format" << endl << "-a<mode> to set the acquisition mode" << endl << "-h<height> to set the AOI width" << endl << "-p<pixelFormat> to set the pixel format" << endl << "-s<serialNumber> to pre-select a certain device. If this device can be found no further user interaction is needed" << endl << "-w<width> to set the AOI width" << endl << "any other string will be interpreted as a name of a setting to load" << endl; } DeviceManager devMgr; Device* pDev = 0; if( !deviceSerial.empty() ) { pDev = devMgr.getDeviceBySerial( deviceSerial ); if( pDev ) { switchFromGenericToGenICamInterface( pDev ); } } if( !pDev ) { pDev = getDeviceFromUserInput( devMgr ); } if( pDev == 0 ) { cout << "Unable to continue!"; PRESS_A_KEY_AND_RETURN }