// // 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"; } }
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; }