/*============================================================================= Copyright (C) 2012 - 2016 Allied Vision Technologies. All Rights Reserved. Redistribution of this file, in original or modified form, without prior written consent of Allied Vision Technologies is prohibited. ------------------------------------------------------------------------------- File: FindCameras.cpp Description: Find and print a custom string for each known customized camera. ------------------------------------------------------------------------------- THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =============================================================================*/ #include #include #include #include "FindCameras.h" #include "CameraFactory.h" #include "VimbaCPP/Include/VimbaCPP.h" #include "Common/StreamSystemInfo.h" #include "Common/ErrorCodeToMessage.h" namespace AVT { namespace VmbAPI { namespace Examples { // // Detects all connected physical cameras and creates polymorphic classes (all inheriting from Vimba Camera class) // depending on the camera's interface type. // Starts up the API // Creates the objects and prints them out // Shuts down the API and exits // void FindCameras::Print() { VimbaSystem& sys = VimbaSystem::GetInstance(); // Get a reference to the VimbaSystem singleton VmbErrorType err = sys.Startup(); // Initialize the Vimba API CameraPtrVector cameras; // A vector of std::shared_ptr objects std::string strName; // The name of the cam VmbInterfaceType interfaceType; // The interface type of the cam std::string strInfo; // The custom information std::stringstream strError; if( VmbErrorSuccess == err ) { std::cout<<"Vimba C++ API Version "<GetName( strName ); if( VmbErrorSuccess != err ) { strError << "[Could not get camera name. Error code: " << err <<"("<GetInterfaceType( interfaceType ); if( VmbErrorSuccess != err ) { strError << "[Could not get camera interface. Error code: " << err << "("<addonFireWire( strInfo ); break; } case VmbInterfaceEthernet: { GigECamera_t gcam = SP_DYN_CAST( *iter, GigECamera ); if ( gcam != NULL ) gcam->addonGigE( strInfo ); break; } case VmbInterfaceUsb: { USBCamera_t ucam = SP_DYN_CAST( *iter, USBCamera ); if ( ucam != NULL ) ucam->addonUSB( strInfo ); break; } case VmbInterfaceCL: { CLCamera_t ccam = SP_DYN_CAST( *iter, CLCamera ); if ( ccam != NULL ) ccam->addonCL( strInfo ); break; } default: { break; } } } std::cout <<"/// Camera Name: " << strName <<"\n/// Custom Info: " << strInfo <<"\n\n"; } } else { std::cout << "Could not list cameras. Error code: " << err <<"("<