bool Flea3Camera::RequestSingle() { if (config_.trigger_source == Flea3Dyn_ts_sw) { if (PollForTriggerReady()) { return FireSoftwareTrigger(); } return false; } return true; }
int CameraPointGrey::init(bool isTrigger) { PrintBuildInfo(); error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError(error); return -1; } printf("Number of cameras detected: %u\n", numCameras); if (numCameras /*< 1*/ != 2) { printf( "Insufficient number of cameras! Please check.\n" ); return -1; } ppCameras = new FlyCapture2::Camera*[numCameras]; // Connect to all detected cameras and attempt to set them to // a common video mode and frame rate for (unsigned int i = 0; i < numCameras; i++) { ppCameras[i] = new FlyCapture2::Camera(); // PGRGuid guid PGRGuid guid; error = busMgr.GetCameraFromIndex(i, &guid); if (error != PGRERROR_OK) { PrintError(error); return -1; } //停止捕获和连接,以防之前的错误 ppCameras[i]->StopCapture(); ppCameras[i]->Disconnect(); // Connect to a camera error = ppCameras[i]->Connect(&guid); if (error != PGRERROR_OK) { PrintError(error); return -1; } // Get the camera information CameraInfo camInfo; error = ppCameras[i]->GetCameraInfo(&camInfo); if (error != PGRERROR_OK) { PrintError(error); return -1; } PrintCameraInfo(&camInfo); { // Check for external trigger support TriggerModeInfo triggerModeInfo; error = ppCameras[i]->GetTriggerModeInfo(&triggerModeInfo); if (error != PGRERROR_OK) { PrintError(error); return -1; } if (triggerModeInfo.present != true) { printf( "Camera does not support external trigger!\n" ); return -1; } // Get current trigger settings TriggerMode triggerMode; error = ppCameras[i]->GetTriggerMode(&triggerMode); if (error != PGRERROR_OK) { PrintError(error); return -1; } // Set camera to trigger mode 0 triggerMode.onOff = isTrigger; // on or off triggerMode.mode = 0; triggerMode.parameter = 0; triggerMode.source = 0; // Triggering the camera externally using source 0, i.e., GPIO0. error = ppCameras[i]->SetTriggerMode(&triggerMode); if (error != PGRERROR_OK) { PrintError(error); return -1; } if (isTrigger) { // Poll to ensure camera is ready bool retVal = PollForTriggerReady(ppCameras[i]); if (!retVal) { printf("\nError polling for trigger ready!\n"); return -1; } } } { Mode k_fmt7Mode = MODE_0; PixelFormat k_fmt7PixFmt = PIXEL_FORMAT_MONO8; // Query for available Format 7 modes Format7Info fmt7Info; bool supported; fmt7Info.mode = k_fmt7Mode; error = ppCameras[i]->GetFormat7Info(&fmt7Info, &supported); if (error != PGRERROR_OK) { PrintError(error); return -1; } PrintFormat7Capabilities( fmt7Info ); if ((k_fmt7PixFmt & fmt7Info.pixelFormatBitField) == 0) { printf("Pixel format is not supported\n"); // Pixel format not supported! return -1; } Format7ImageSettings fmt7ImageSettings; fmt7ImageSettings.mode = k_fmt7Mode; fmt7ImageSettings.offsetX = 0; fmt7ImageSettings.offsetY = 0; fmt7ImageSettings.width = fmt7Info.maxWidth; fmt7ImageSettings.height = fmt7Info.maxHeight; fmt7ImageSettings.pixelFormat = k_fmt7PixFmt; bool valid; Format7PacketInfo fmt7PacketInfo; // Validate the settings to make sure that they are valid error = ppCameras[i]->ValidateFormat7Settings( &fmt7ImageSettings, &valid, &fmt7PacketInfo); if (error != PGRERROR_OK) { PrintError(error); return -1; } if (!valid ) { printf("Format7 settings are not valid\n"); // Settings are not valid return -1; } // Set the settings to the camera error = ppCameras[i]->SetFormat7Configuration( &fmt7ImageSettings, // fmt7PacketInfo.recommendedBytesPerPacket ); (unsigned int)516); if (error != PGRERROR_OK) { PrintError(error); return -1; } } VideoMode videoMode = VIDEOMODE_1024x768Y8; FrameRate frameRate = FRAMERATE_3_75; bool isSupported; ppCameras[i]->GetVideoModeAndFrameRateInfo(videoMode, frameRate, &isSupported); if (!isSupported) { printf("Video mode 1024x768 8bit, Frame rate 3.75, are not supported!\n"); return -1; } ppCameras[i]->SetVideoModeAndFrameRate(videoMode, frameRate); // Camera is ready, start capturing images error = ppCameras[i]->StartCapture(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Set all cameras to a specific mode and frame rate so they can be synchronized // Retrieve frame rate property Property frmRate; frmRate.type = FRAME_RATE; error = ppCameras[i]->GetProperty(&frmRate); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Framse rate is %3.2f fps\n", frmRate.absValue ); /*************** property setting ***************/ Property prop; //prop.type = BRIGHTNESS; //prop.type = AUTO_EXPOSURE; //prop.type = SHARPNESS; prop.type = GAMMA; ppCameras[i]->GetProperty(&prop); prop.absValue = 1.0f; ppCameras[i]->SetProperty(&prop, true); //prop.type = PAN; //prop.type = TILT; /* prop.type = SHUTTER; ppCameras[i]->GetProperty(&prop); prop.absValue = 28.0f; ppCameras[i]->SetProperty(&prop, true); */ prop.type = GAIN; ppCameras[i]->GetProperty(&prop); prop.absValue = 0.0f; ppCameras[i]->SetProperty(&prop, true); } return 0; }