// // Starts Vimba // Gets all connected cameras // And prints out information about the camera name, model name, serial number, ID and the corresponding interface ID // void ListCameras::Print() { VimbaSystem& sys = VimbaSystem::GetInstance(); // Get a reference to the VimbaSystem singleton std::cout<<"Vimba Version V"<<sys<<"\n"; // Print out version of Vimba VmbErrorType err = sys.Startup(); // Initialize the Vimba API CameraPtrVector cameras; // A vector of std::shared_ptr<AVT::VmbAPI::Camera> objects std::stringstream strError; if( VmbErrorSuccess == err ) { err = sys.GetCameras( cameras ); // Fetch all cameras known to Vimba if( VmbErrorSuccess == err ) { std::cout << "Cameras found: " << cameras.size() <<"\n\n"; // Query all static details of all known cameras and print them out. // We don't have to open the cameras for that. std::for_each( cameras.begin(), cameras.end(), PrintCameraInfo ); } else { std::cout << "Could not list cameras. Error code: " << err << "("<<AVT::VmbAPI::Examples::ErrorCodeToMessage(err)<<")"<< "\n"; } sys.Shutdown(); // Close Vimba } else { std::cout << "Could not start system. Error code: " << err <<"("<<AVT::VmbAPI::Examples::ErrorCodeToMessage(err)<<")"<< "\n"; } }
// // Prints out all features and their values and details of a given camera. // If no camera ID is provided, the first camera will be used. // Starts and stops the API // Opens and closes the camera // // Parameters: // [in] CameraID The ID of the camera to work // void ListFeatures::Print( std::string CameraID ) { VimbaSystem& sys = VimbaSystem::GetInstance(); // Get a reference to the VimbaSystem singleton std::cout << "Vimba Version V" << sys << "\n"; // Print out version of Vimba VmbErrorType err = sys.Startup(); // Initialize the Vimba API FeaturePtrVector features; // A vector of std::shared_ptr<AVT::VmbAPI::Feature> objects CameraPtr pCamera = CameraPtr(); // Our camera std::stringstream strError; if( VmbErrorSuccess == err ) { if( CameraID.empty() ) // If no ID was provided use the first camera { CameraPtrVector cameras; err = sys.GetCameras( cameras ); if( VmbErrorSuccess == err && !cameras.empty() ) { err = cameras[0]->Open( VmbAccessModeFull ); // Open the camera if( VmbErrorSuccess == err ) { pCamera = cameras[0]; err = pCamera->GetID( CameraID ); } } } else { err = sys.OpenCameraByID( CameraID.c_str(), VmbAccessModeFull, pCamera ); // Get and open the camera } if( NULL != pCamera ) { std::cout << "Printing all features of camera with ID: " << CameraID << "\n"; err = pCamera->GetFeatures( features ); // Fetch all features of our cam if( VmbErrorSuccess == err ) { // Query all static details as well as the value of all fetched features and print them out. std::for_each( features.begin(), features.end(), PrintFeatures ); } else { std::cout << "Could not get features. Error code: " << err << " (" << AVT::VmbAPI::Examples::ErrorCodeToMessage( err ) << ")" << "\n"; } pCamera->Close(); } else { std::cout << "Could not open camera or no camera available. Error code: " << err << " (" << AVT::VmbAPI::Examples::ErrorCodeToMessage( err ) << ")" << "\n"; } sys.Shutdown(); } else { std::cout << "Could not start system. Error code: " << err << " (" << AVT::VmbAPI::Examples::ErrorCodeToMessage( err ) << ")" << "\n"; } }
// // Queries and lists all known camera // void CAsynchronousGrabDlg::UpdateCameraListBox() { // Get all cameras currently connected to Vimba CameraPtrVector cameras = m_ApiController.GetCameraList(); // Simply forget about all cameras known so far m_ListBoxCameras.ResetContent(); m_cameras.clear(); // And query the camera details again for( CameraPtrVector::const_iterator iter = cameras.begin(); cameras.end() != iter; ++iter ) { std::string strCameraName; std::string strCameraID; if( VmbErrorSuccess != (*iter)->GetName( strCameraName ) ) { strCameraName = "[NoName]"; } // If for any reason we cannot get the ID of a camera we skip it if( VmbErrorSuccess == (*iter)->GetID( strCameraID ) ) { std::string strInfo = strCameraName + " " + strCameraID; m_ListBoxCameras.AddString( CString( strInfo.c_str() ) ); m_cameras.push_back( strCameraID ); } else { Log( _TEXT("Could not get camera ID") ); } } // Select first cam if none is selected if ( -1 == m_ListBoxCameras.GetCurSel() && 0 < m_cameras.size() ) { m_ListBoxCameras.SetCurSel( 0 ); } m_ButtonStartStop.EnableWindow( 0 < m_cameras.size() || m_bIsStreaming ); }
bool VimbaSourceSink::Init() { VmbErrorType err=system.Startup(); CameraPtrVector cameras; if( VmbErrorSuccess == err ) { // now find all cameras err = system.GetCameras( cameras ); // Fetch all cameras known to Vimba if( VmbErrorSuccess == err ) { if (cameras.size()>0) { if (cameras.size()>1) { qDebug() << "Cameras found: " << cameras.size(); // should also implement Qinputdialog to let the user choose which one to use for (uint i=0;i<cameras.size();i++) { CameraPtr cam=cameras[i]; std::string namestr; err=cam->GetName(namestr); qDebug()<<"Next Camera is: "<<QString::fromStdString(namestr); } } // now open the first one only pCamera=cameras[0]; std::string camID; std::string namestr; err=pCamera->GetName(namestr); err=pCamera->GetID(camID); if( VmbErrorSuccess == err ) { qDebug()<<"Opening camera "<<QString::fromStdString(namestr); err=pCamera->Open(VmbAccessModeFull); if (err==VmbErrorSuccess) { //camera successfully opened. Now do some camera initialisation steps // Set the GeV packet size to the highest possible value // (In this example we do not test whether this cam actually is a GigE cam) FeaturePtr pCommandFeature; if ( VmbErrorSuccess == pCamera->GetFeatureByName( "GVSPAdjustPacketSize", pCommandFeature )) { if ( VmbErrorSuccess == pCommandFeature->RunCommand() ) { bool bIsCommandDone = false; do { if ( VmbErrorSuccess != pCommandFeature->IsCommandDone( bIsCommandDone )) { break; } } while ( false == bIsCommandDone ); } } // get/set some features FeaturePtr pFeature; // Set Trigger source to fixedRate err=pCamera->GetFeatureByName("TriggerSource",pFeature); if (err==VmbErrorSuccess) { pFeature->SetValue("FixedRate"); } // get Camera timestamp frequency err=pCamera->GetFeatureByName("GevTimestampTickFrequency",pFeature); if (err==VmbErrorSuccess) { err=pFeature->GetValue(camFreq); if (err==VmbErrorSuccess) { // qDebug()<<"Camera freq is "<<(1.0*camFreq); } else { qDebug()<<"Could not extract freq: "<<err; } } else { qDebug()<<"Could not query frequency: "<<err<<" => Will use LUT"; if (namestr=="GE1050") { camFreq=79861111; } else if (namestr=="GE1910") { camFreq=79861111; } else if (namestr=="GE2040") { camFreq=79861111; } else { qDebug()<<"Model not yet in LUT => unreliable timestamps"; camFreq=79861111; } } // Set acquisition mode to continuous err=pCamera->GetFeatureByName("AcquisitionMode",pFeature); if (err==VmbErrorSuccess) { pFeature->SetValue("Continuous"); // this should be continuous } // set/get maximum height and width of current camera err=pCamera->GetFeatureByName("WidthMax",pFeature); if (err==VmbErrorSuccess) { pFeature->GetValue(maxWidth); } err=pCamera->GetFeatureByName("Width",pFeature); if (err==VmbErrorSuccess) { pFeature->SetValue(maxWidth); pFeature->GetValue(width); // this should be continuous } err=pCamera->GetFeatureByName("HeightMax",pFeature); if (err==VmbErrorSuccess) { pFeature->GetValue(maxHeight); } err=pCamera->GetFeatureByName("Height",pFeature); if (err==VmbErrorSuccess) { pFeature->SetValue(maxHeight); pFeature->GetValue(height); // this should be continuous } // make sure shutter time is manual err=pCamera->GetFeatureByName("ExposureAuto",pFeature); if (err==VmbErrorSuccess) { pFeature->SetValue("Off"); // this should be manual exposure setting } // now let the user select the pixel format to be used std::vector<std::string> pixF; QStringList items; pixF=listPixelFormats(); for (uint i=0;i<pixF.size();i++) { if (pixF[i]=="Mono8") { items<<"MONO8"; } else if (pixF[i]=="Mono12") { items<<"MONO12"; } else if (pixF[i]=="Mono14") { items<<"MONO14"; } else if (pixF[i]=="BayerRG8") { items<<"BAYERRG8"; } else if (pixF[i]=="BayerGB8") { items<<"BAYERGB8"; } else { if (!QString::fromStdString(pixF[i]).contains("Packed")) { qDebug()<<"This pixel-mode not yet available in Gigaviewer: "<<QString::fromStdString(pixF[i]); } } } bool ok; QString item = QInputDialog::getItem(NULL, "Pixel format", "Selection options:", items, 0, false, &ok); if (ok && !item.isEmpty()) { format=item; setFormat(format); // qDebug()<<"Selected "<<format; } // construct the frame observer to the camera frameWatcher=new VimbaFrameObserver( pCamera, parent ); } else { // camera did not open successfully return false; } } } else { qDebug()<<"Zero cameras found"; return false; } } else { qDebug() << "Could not list cameras. Error code: " << err; return false; } } else { qDebug() << "Could not start system. Error code: " << err; return false; } return true; }