bool PGRCamera::connectToCamera() { Error error; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); TEST_ERR(error); printf( "Number of PGR cameras detected: %u\n", numCameras ); if ( numCameras < 1 ) { printf( "Insufficient number of cameras... exiting\n" ); return false; } PGRGuid guid; error = busMgr.GetCameraFromIndex(0, &guid); TEST_ERR(error); // Connect to a camera error = cam.Connect(&guid); TEST_ERR(error); return true; }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); Error error; // Since this application saves images in the current folder // we must ensure that we have permission to write to this folder. // If we do not have permission, fail right away. FILE* tempFile = fopen("test.txt", "w+"); if (tempFile == NULL) { printf("Failed to create file in current folder. Please check permissions.\n"); return -1; } fclose(tempFile); remove("test.txt"); BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } if ( numCameras < 1 ) { printf( "No camera detected.\n" ); return -1; } else { printf( "Number of cameras detected: %u\n", numCameras ); } PGRGuid guid; error = busMgr.GetCameraFromIndex(0, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Running the first camera.\n" ); RunCamera( guid ); printf( "Done! Press Enter to exit...\n" ); getchar(); return 0; }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); Error error; // Since this application saves images in the current folder // we must ensure that we have permission to write to this folder. // If we do not have permission, fail right away. FILE* tempFile = fopen("test.txt", "w+"); if (tempFile == NULL) { cout << "Failed to create file in current folder. Please check permissions." << endl; return -1; } fclose(tempFile); remove("test.txt"); BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } cout << "Number of cameras detected: " << numCameras << endl; for (unsigned int i=0; i < numCameras; i++) { PGRGuid guid; error = busMgr.GetCameraFromIndex(i, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } RunSingleCamera( guid ); } cout << "Done! Press Enter to exit..." << endl; cin.ignore(); return 0; }
extern "C" void point_grey_set_white_balance(int red, int blue) { BusManager busMgr; unsigned int nrCameras; check_point_grey(busMgr.GetNumOfCameras(&nrCameras)); PGRGuid guid; check_point_grey(busMgr.GetCameraFromIndex(0, &guid)); Camera cam; check_point_grey(cam.Connect(&guid)); PropertyInfo p; p.type = WHITE_BALANCE; check_point_grey(cam.GetPropertyInfo(&p)); Property prop; prop.type = WHITE_BALANCE; check_point_grey(cam.GetProperty(&prop)); prop.valueA = red; prop.valueB = blue; prop.onOff = 1; check_point_grey(cam.SetProperty(&prop)); cam.Disconnect(); }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); std::ofstream outfile; outfile.open("CommandLog.txt", std::ios_base::app); Error error; repeat: time_t rawtime; struct tm * ptm; time ( &rawtime ); ptm = gmtime ( &rawtime ); if (int(ptm->tm_sec)==0 || ptm->tm_sec==30) { outfile << "Current time: " << (ptm->tm_hour)%24 << ":" << (ptm->tm_min) << ":" << (ptm->tm_sec) << endl; // Since this application saves images in the current folder // we must ensure that we have permission to write to this folder. // If we do not have permission, fail right away. FILE* tempFile = fopen("test.txt", "w+"); if (tempFile == NULL) { outfile << "Failed to create file in current folder. Please check permissions." << endl; return -1; } fclose(tempFile); remove("test.txt"); BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } for (unsigned int i=0; i < numCameras; i++) { float w = 3500.0; // This line is where the shutter value has been set (3.5 seconds in this case) float L; // The camera's first image at boot will use the previous shutter value from last use. This variable is used to remind us that the first image cannot be trusted if (L < 1.0) { outfile << "Ignore This Image!!" << w << endl; L = L+1.0; PGRGuid guid; error = busMgr.GetCameraFromIndex(i, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } RunSingleCamera( guid , 4 , w); } else { L = L+1.0; outfile << "Shutter time set to: " << w << endl; PGRGuid guid; error = busMgr.GetCameraFromIndex(i, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } RunSingleCamera( guid , 4 , w); } outfile << "Done!" << endl; } } goto repeat; return 0; }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); const int k_numImages = 100; Error error; //The vector to be used for storing images temporarily std::vector<Image> vecImages; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Number of cameras detected: %u\n", numCameras ); if ( numCameras < 1 ) { printf( "Insufficient number of cameras... press Enter to exit.\n" ); getchar(); return -1; } vecImages.resize(k_numImages * numCameras); Camera** ppCameras = new 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 Camera(); PGRGuid guid; error = busMgr.GetCameraFromIndex( i, &guid ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // 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); // Set all cameras to a specific mode and frame rate so they // can be synchronized error = ppCameras[i]->SetVideoModeAndFrameRate( VIDEOMODE_640x480Y8, FRAMERATE_30 ); if (error != PGRERROR_OK) { PrintError( error ); printf( "Error starting cameras. \n" "This example requires cameras to be able to set to 640x480 Y8 at 30fps. \n" "If your camera does not support this mode, please edit the source code and recompile the application. \n" "Press Enter to exit. \n"); getchar(); return -1; } } error = Camera::StartSyncCapture( numCameras, (const Camera**)ppCameras ); if (error != PGRERROR_OK) { PrintError( error ); printf( "Error starting cameras. \n" "This example requires cameras to be able to set to 640x480 Y8 at 30fps. \n" "If your camera does not support this mode, please edit the source code and recompile the application. \n" "Press Enter to exit. \n"); getchar(); return -1; } Image image; for ( int j = 0; j < k_numImages; j++ ) { // Display the timestamps for all cameras to show that the image // capture is synchronized for each image for ( unsigned int i = 0; i < numCameras; i++ ) { error = ppCameras[i]->RetrieveBuffer( &image ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } TimeStamp timestamp = image.GetTimeStamp(); printf( "Cam %d - Frame %d - TimeStamp [%d %d]\n", i, j, timestamp.cycleSeconds, timestamp.cycleCount); vecImages[i + numCameras * j].DeepCopy( &image ); } } PropertyInfo propInfo; propInfo.type = FRAME_RATE; error = ppCameras[0]->GetPropertyInfo( &propInfo ); if(error != PGRERROR_OK) { PrintError(error); return -1; } float frameRateToUse = 15.0f; if(propInfo.present == true) { Property prop; prop.type = FRAME_RATE; error = ppCameras[0]->GetProperty( &prop ); if(error == PGRERROR_OK) { PrintError(error); } frameRateToUse = prop.absValue; } printf("Writing .avi files with frame rate of %3.1f\n",frameRateToUse); SaveAviHelper(MJPG, vecImages, numCameras, frameRateToUse); for( unsigned int i = 0; i < numCameras; i++ ) { ppCameras[i]->StopCapture(); ppCameras[i]->Disconnect(); delete ppCameras[i]; } delete [] ppCameras; printf( "Done! Press Enter to exit...\n" ); getchar(); return 0; }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); const int k_numImages = 100; Error error; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Number of cameras detected: %u\n", numCameras ); if ( numCameras < 1 ) { printf( "Insufficient number of cameras... press Enter to exit.\n" ); getchar(); return -1; } Camera** ppCameras = new 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 Camera(); PGRGuid guid; error = busMgr.GetCameraFromIndex( i, &guid ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // 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); // Set all cameras to a specific mode and frame rate so they // can be synchronized error = ppCameras[i]->SetVideoModeAndFrameRate( VIDEOMODE_640x480Y8, FRAMERATE_30 ); if (error != PGRERROR_OK) { PrintError( error ); printf( "Error starting cameras. \n" "This example requires cameras to be able to set to 640x480 Y8 at 30fps. \n" "If your camera does not support this mode, please edit the source code and recompile the application. \n" "Press Enter to exit. \n"); getchar(); return -1; } } error = Camera::StartSyncCapture( numCameras, (const Camera**)ppCameras ); if (error != PGRERROR_OK) { PrintError( error ); printf( "Error starting cameras. \n" "This example requires cameras to be able to set to 640x480 Y8 at 30fps. \n" "If your camera does not support this mode, please edit the source code and recompile the application. \n" "Press Enter to exit. \n"); getchar(); return -1; } for ( int j = 0; j < k_numImages; j++ ) { // Display the timestamps for all cameras to show that the image // capture is synchronized for each image for ( unsigned int i = 0; i < numCameras; i++ ) { Image image; error = ppCameras[i]->RetrieveBuffer( &image ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } TimeStamp timestamp = image.GetTimeStamp(); printf( "Cam %d - Frame %d - TimeStamp [%d %d]\n", i, j, timestamp.cycleSeconds, timestamp.cycleCount); } } for ( unsigned int i = 0; i < numCameras; i++ ) { ppCameras[i]->StopCapture(); ppCameras[i]->Disconnect(); delete ppCameras[i]; } delete [] ppCameras; printf( "Done! Press Enter to exit...\n" ); getchar(); return 0; }
int main(int argc, char* argv[]) { // instructions on how to use this software cout << "Welcome to the ASI software.\n There are two modes - calibration and data mode. The calibration mode enables you to take pictures from each camera one at a time while changing the orientation of the checkerboard pattern with each 'run'. The Scanning mode is where a moving slit is projected onto the object and images taken by both cameras are synchronized with it." << endl; cout << "The general syntax of the command is \n\n" << endl; cout << "./out -mode -count -int -color\n\n" << endl; Error error; CameraInfo camInfo; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf("cameras: %u\n", numCameras); // create a new array of cameras Camera* pcam[2] ; // now we do the formalities needed to establish a connection for (unsigned int i=0; i<numCameras; i++) { // connect to a camera PGRGuid guid; pcam[i] = new Camera(); error = busMgr.GetCameraFromIndex( i, &guid ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } error = pcam[i]->Connect(&guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Get the camera information error = pcam[i]->GetCameraInfo( &camInfo ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // uncomment the following line if you really care about the camera info // PrintCameraInfo(&camInfo); // Next we turn isochronous images capture ON for both cameras error = pcam[i]->StartCapture(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } } Image rawImage, convertedImage; // prepare the image object and keep // checking command line parameters bool mode_specified = false, count_specified = false, int_specified = false, color_specified = false; // setting defaults. mode is slit, no of images is 50, intensity is midway and color is white. int mode = 0, numImages = 50, intensity = 255, color = 0; // parse command line arguments for (int cmd = 1; cmd < argc - 1; cmd += 2) { if (!strcmp(argv[cmd],"-mode")) { if (!strcmp(argv[cmd + 1], "slit")) { mode_specified = true; cout << "mode is slitscan" << endl; mode = 0; } else if (!strcmp(argv[cmd + 1], "calib")) { mode_specified = true; cout << "mode is calibration" << endl; mode = 1; } } else if (!strcmp(argv[cmd],"-count")) { count_specified = true; cout << "no of images is " << atoi(argv[cmd + 1]) << endl; numImages = atoi(argv[cmd + 1]); } else if (!strcmp(argv[cmd],"-int")) { int_specified = true; cout << "brightness of illumination is " << atoi(argv[cmd + 1]) << endl; intensity = atoi(argv[cmd + 1]); } else if (!strcmp(argv[cmd],"-color")) { if (mode == 0){ if (!strcmp(argv[cmd + 1], "white")) { color_specified = true; cout << "color is white" << endl; color = 0; } else if (!strcmp(argv[cmd + 1], "green")) { color_specified = true; cout << "color is green" << endl; color = 1; } } else if (mode == 1) { cout << "Mode is calibration, will use only white." << endl; } } } // handling default cases in case of not entering arguments.. if (mode_specified == false) { cout << "Mode not specified. going with slitscan." << endl; } if (count_specified == false) { cout << "No of images not specified, default is 50." << endl; } if (int_specified == false) { cout << "Intensity not specified, going with max" << endl; } if (color_specified == false) { cout << "Colour not specified, default is white" << endl; } std::vector<Image> vecImages1; vecImages1.resize(numImages); std::vector<Image> vecImages2; vecImages2.resize(numImages); int slitRow = 1200, slitCol = 1600, slitStart = 0.3*slitRow, slitMove = 0.6*slitRow/50; cv::Mat projectedSlit(slitRow, slitCol, CV_8UC1); cv::cvtColor(projectedSlit, projectedSlit, CV_GRAY2RGB); // we'll create a namedWindow which can be closed by us cvNamedWindow("Image1", CV_WINDOW_NORMAL); cvSetWindowProperty("Image1", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); cv::imshow("Image1", projectedSlit); cv::waitKey(1000); cv::Vec3b black, green, white, slit_color; black.val[0] = 0; black.val[1] = 0; black.val[2] = 0; green.val[0] = 0; green.val[1] = intensity; green.val[2] = 0; white.val[0] = intensity; white.val[1] = intensity; white.val[2] = intensity; // set the color of the slit based on cmdline parameters if (color == 0) { slit_color = white; } else if (color == 1) { slit_color = green; } cvStartWindowThread(); for (int j=0; j < numImages; j++ ) { // first display the window with the slit // We will update the Mat object and update the slit position // if the mode is slitscan, prepare the slit if (mode == 0) { for (int a = 400; a < 800; a++) { if (j > 0) { projectedSlit.at<cv::Vec3b>(cv::Point(a, slitStart + (j - 1)*slitMove)) = black; } projectedSlit.at<cv::Vec3b>(cv::Point(a, slitStart + j*slitMove)) = slit_color; } cv::imshow("Image1", projectedSlit); cv::waitKey(1); } // if the mode is calibration, we just show a white screen if (mode == 1) { cout << "Setting static illumination for calibration" << endl; projectedSlit = cv::Scalar(intensity, intensity, intensity); cv::imshow("Image1", projectedSlit); cv::waitKey(1); } // then we capture the image from both cameras for (unsigned int cam=0; cam < numCameras; cam++) { error = pcam[cam]->RetrieveBuffer( &rawImage ); if (error != PGRERROR_OK) { PrintError( error ); continue; } if(cam==0) { vecImages1[j].DeepCopy(&rawImage); } else { vecImages2[j].DeepCopy(&rawImage); } } if (mode == 1) { // cvDestroyWindow("Image1"); cv::waitKey(0); cout << "Captured image " << j << " of " << numImages << endl; // cout << "Press ENTER to continue..."; // cin.ignore(); } } // then destroy the window cvDestroyWindow("Image1"); //Process and store the images captured if (numCameras > 0) { printf("Saving images.. please wait\n"); for (int j=0; j < numImages; j++) { error = vecImages1[j].Convert( PIXEL_FORMAT_RGB, &convertedImage ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Create a unique filename char filename[512]; sprintf( filename, "./images/cam--%d-%d.tiff", 0, j); // Save the image. If a file format is not passed in, then the file // extension is parsed to attempt to determine the file format. error = convertedImage.Save( filename ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } //Do the same for the second camera error = vecImages2[j].Convert( PIXEL_FORMAT_RGB, &convertedImage ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Create a unique filename char filename2[512]; sprintf( filename2, "./images/cam--%d-%d.tiff", 1, j); // Save the image. If a file format is not passed in, then the file // extension is parsed to attempt to determine the file format. error = convertedImage.Save( filename2 ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } } for ( unsigned int i = 0; i < numCameras; i++ ) { pcam[i]->StopCapture(); pcam[i]->Disconnect(); delete pcam[i]; } } // delete [] pcam; printf( "Done! Press Enter to exit...\n" ); getchar(); return 0; }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); const Mode k_fmt7Mode = MODE_0; const PixelFormat k_fmt7PixFmt = PIXEL_FORMAT_MONO8; const int k_numImages = 10; Error error; // Since this application saves images in the current folder // we must ensure that we have permission to write to this folder. // If we do not have permission, fail right away. FILE* tempFile = fopen("test.txt", "w+"); if (tempFile == NULL) { printf("Failed to create file in current folder. Please check permissions.\n"); return -1; } fclose(tempFile); remove("test.txt"); BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Number of cameras detected: %u\n", numCameras ); if ( numCameras < 1 ) { printf( "Insufficient number of cameras... exiting\n" ); return -1; } PGRGuid guid; error = busMgr.GetCameraFromIndex(0, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } Camera cam; // Connect to a camera error = cam.Connect(&guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Get the camera information CameraInfo camInfo; error = cam.GetCameraInfo(&camInfo); if (error != PGRERROR_OK) { PrintError( error ); return -1; } PrintCameraInfo(&camInfo); // Query for available Format 7 modes Format7Info fmt7Info; bool supported; fmt7Info.mode = k_fmt7Mode; error = cam.GetFormat7Info( &fmt7Info, &supported ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } PrintFormat7Capabilities( fmt7Info ); if ( (k_fmt7PixFmt & fmt7Info.pixelFormatBitField) == 0 ) { // Pixel format not supported! printf("Pixel format is not supported\n"); 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 = cam.ValidateFormat7Settings( &fmt7ImageSettings, &valid, &fmt7PacketInfo ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } if ( !valid ) { // Settings are not valid printf("Format7 settings are not valid\n"); return -1; } // Set the settings to the camera error = cam.SetFormat7Configuration( &fmt7ImageSettings, fmt7PacketInfo.recommendedBytesPerPacket ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Start capturing images error = cam.StartCapture(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Retrieve frame rate property Property frmRate; frmRate.type = FRAME_RATE; error = cam.GetProperty( &frmRate ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Frame rate is %3.2f fps\n", frmRate.absValue ); printf( "Grabbing %d images\n", k_numImages ); Image rawImage; for ( int imageCount=0; imageCount < k_numImages; imageCount++ ) { // Retrieve an image error = cam.RetrieveBuffer( &rawImage ); if (error != PGRERROR_OK) { PrintError( error ); continue; } printf( "." ); // Get the raw image dimensions PixelFormat pixFormat; unsigned int rows, cols, stride; rawImage.GetDimensions( &rows, &cols, &stride, &pixFormat ); // Create a converted image Image convertedImage; // Convert the raw image error = rawImage.Convert( PIXEL_FORMAT_BGRU, &convertedImage ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Create a unique filename char filename[512]; sprintf( filename, "%u-%d.bmp", camInfo.serialNumber, imageCount ); // Save the image. If a file format is not passed in, then the file // extension is parsed to attempt to determine the file format. error = convertedImage.Save( filename ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } } printf( "\nFinished grabbing images\n" ); // Stop capturing images error = cam.StopCapture(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Disconnect the camera error = cam.Disconnect(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Done! Press Enter to exit...\n" ); getchar(); return 0; }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); const int k_numImages = 5; Error error; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Number of cameras detected: %u\n", numCameras ); if ( numCameras < 1 ) { printf( "Insufficient number of cameras... exiting\n" ); return -1; } PGRGuid guid; error = busMgr.GetCameraFromIndex(0, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } Camera cam; // Connect to a camera error = cam.Connect(&guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Get the camera information CameraInfo camInfo; error = cam.GetCameraInfo(&camInfo); if (error != PGRERROR_OK) { PrintError( error ); return -1; } PrintCameraInfo(&camInfo); // Check if the camera supports the FRAME_RATE property PropertyInfo propInfo; propInfo.type = FRAME_RATE; error = cam.GetPropertyInfo( &propInfo ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } ExtendedShutterType shutterType = NO_EXTENDED_SHUTTER; if ( propInfo.present == true ) { // Turn off frame rate Property prop; prop.type = FRAME_RATE; error = cam.GetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } prop.autoManualMode = false; prop.onOff = false; error = cam.SetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } shutterType = GENERAL_EXTENDED_SHUTTER; } else { // Frame rate property does not appear to be supported. // Disable the extended shutter register instead. // This is only applicable for Dragonfly. const unsigned int k_extendedShutter = 0x1028; unsigned int extendedShutterRegVal = 0; error = cam.ReadRegister( k_extendedShutter, &extendedShutterRegVal ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } std::bitset<32> extendedShutterBS( extendedShutterRegVal ); if ( extendedShutterBS[31] == true ) { // Set the camera into extended shutter mode error = cam.WriteRegister( k_extendedShutter, 0x80020000 ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } } else { printf( "Frame rate and extended shutter are not supported... exiting\n" ); return -1; } shutterType = DRAGONFLY_EXTENDED_SHUTTER; } // Set the shutter property of the camera Property prop; prop.type = SHUTTER; error = cam.GetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } prop.autoManualMode = false; prop.absControl = true; const float k_shutterVal = 3000.0; prop.absValue = k_shutterVal; error = cam.SetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Shutter time set to %.2fms\n", k_shutterVal ); // Enable timestamping EmbeddedImageInfo embeddedInfo; error = cam.GetEmbeddedImageInfo( &embeddedInfo ); if ( error != PGRERROR_OK ) { PrintError( error ); return -1; } if ( embeddedInfo.timestamp.available != 0 ) { embeddedInfo.timestamp.onOff = true; } error = cam.SetEmbeddedImageInfo( &embeddedInfo ); if ( error != PGRERROR_OK ) { PrintError( error ); return -1; } // Start the camera error = cam.StartCapture(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } for ( int i=0; i < k_numImages; i++ ) { Image image; error = cam.RetrieveBuffer( &image ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } TimeStamp timestamp = image.GetTimeStamp(); printf( "TimeStamp [%d %d]\n", timestamp.cycleSeconds, timestamp.cycleCount); } // Stop capturing images error = cam.StopCapture(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Set the camera back to its original state prop.type = SHUTTER; error = cam.GetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } prop.autoManualMode = true; error = cam.SetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } if ( shutterType == GENERAL_EXTENDED_SHUTTER ) { Property prop; prop.type = FRAME_RATE; error = cam.GetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } prop.autoManualMode = true; prop.onOff = true; error = cam.SetProperty( &prop ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } } else if ( shutterType == DRAGONFLY_EXTENDED_SHUTTER ) { const unsigned int k_extendedShutter = 0x1028; unsigned int extendedShutterRegVal = 0; error = cam.ReadRegister( k_extendedShutter, &extendedShutterRegVal ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } std::bitset<32> extendedShutterBS( extendedShutterRegVal ); if ( extendedShutterBS[31] == true ) { // Set the camera into extended shutter mode error = cam.WriteRegister( k_extendedShutter, 0x80000000 ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } } } // Disconnect the camera error = cam.Disconnect(); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Done! Press Enter to exit...\n" ); getchar(); return 0; }
VideoSource::VideoSource(): m_buffer(NULL) { Error error; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) PrintErrorAndExit(error); printf("Number of cameras detected: %u\n", numCameras); assert(numCameras > 0); PGRGuid guid; error = busMgr.GetCameraFromIndex(0, &guid); if (error != PGRERROR_OK) PrintErrorAndExit(error); error = cam.Connect(&guid); if (error != PGRERROR_OK) PrintErrorAndExit(error); CameraInfo camInfo; error = cam.GetCameraInfo(&camInfo); if (error != PGRERROR_OK) PrintErrorAndExit(error); printf( "\n*** CAMERA INFORMATION ***\n" "Serial number - %u\n" "Camera model - %s\n" "Camera vendor - %s\n" "Sensor - %s\n" "Resolution - %s\n" "Firmware version - %s\n" "Firmware build time - %s\n\n", camInfo.serialNumber, camInfo.modelName, camInfo.vendorName, camInfo.sensorInfo, camInfo.sensorResolution, camInfo.firmwareVersion, camInfo.firmwareBuildTime); VideoMode vm; FrameRate fr; // Start capturing images at 640x480xY8 // You probably need to change this stuff for your camera mirSize = ImageRef(IMAGE_W, IMAGE_H); bool bStatus; int i,x; for (i = VIDEOMODE_160x120YUV444; i < NUM_VIDEOMODES-1; i++) { for (x = FRAMERATE_1_875; x < NUM_FRAMERATES-1; x++) { error = cam.GetVideoModeAndFrameRateInfo((VideoMode)i, (FrameRate)x, &bStatus); if (error != PGRERROR_OK) { PrintErrorAndExit(error); } if (bStatus == TRUE) { printf("found at %d %d\n", i, x); break; } } } error = cam.SetVideoModeAndFrameRate(VIDEOMODE_640x480RGB, FRAMERATE_120); if (error != PGRERROR_OK) { // my PT camera doesnt support these mode changes. // PrintErrorAndExit(error); } cam.GetVideoModeAndFrameRate(&vm, &fr); error = cam.StartCapture(); if (error != PGRERROR_OK) PrintErrorAndExit(error); };
int instantiateRig(int* ids, int camCount, int mid) { PrintBuildInfo(); //image_geometry::PinholeCameraModel model_l; //image_geometry::PinholeCameraModel model_r; //*****************************************Camera Parameters************************************// master_id = mid; error = busMgr.GetNumOfCameras(&numCameras); ppCameras = new Camera*[numCameras]; cam_ID = new int[numCameras]; cam_Order = new int[numCameras]; //14234066 && tempcamInfo.serialNumber!=14234097 ///////////////////////////////////////////////////////////// // read cam info file to initalise numCam, cam_ID, if (error != PGRERROR_OK) { PrintError( error ); return -1; } cout << "Number of cameras detected: " << numCameras << endl; if ( numCameras < 1) // changed to 2 { cout << "Insufficient number of cameras... exiting" << endl; return -1; } ///////////////////////////// // Instantiating Cameras // ///////////////////////////// while(camera_found != numCameras) { ppCameras[camera_found] = new Camera(); PGRGuid guid; error = busMgr.GetCameraFromIndex(camera_test, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } error = ppCameras[camera_test]->Connect(&guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } error = ppCameras[camera_found]->GetCameraInfo(&tempcamInfo); cout<<tempcamInfo.serialNumber<<" cam_ID"<<endl; int camNotFound = 1; //for(int i = 0; i<numCameras; i++) // camNotFound= camNotFound* int (tempcamInfo.serialNumber!=cam_ID[i]); if(!camNotFound) { camera_test++; continue; } else { camera_found++; camera_test++; } } for(int i = 0; i < camCount; i++){ for(int j = 0; i < numCameras; j++){ ppCameras[camera_found]->GetCameraInfo(&tempcamInfo); if(ids[i] == tempcamInfo.serialNumber) swap(ppCameras[i], ppCameras[j]); } } for(int i = camCount; i < numCameras; i++){ diconsingleCam(ppCameras[i]); } numCameras = camCount; /////////////////////////////////////////////// // Powering up // /////////////////////////////////////////////// // Power on the camera const unsigned int k_cameraPower = 0x610; const unsigned int k_powerVal = 0x80000000; for(int i = 0; i<numCameras;i++) { error = ppCameras[i]->WriteRegister( k_cameraPower, k_powerVal ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } const unsigned int millisecondsToSleep = 100; unsigned int regVal = 0; unsigned int retries = 10; // Wait for camera to complete power-up do { #if defined(WIN32) || defined(WIN64) Sleep(millisecondsToSleep); #else usleep(millisecondsToSleep * 1000); #endif error = ppCameras[i]->ReadRegister(k_cameraPower, ®Val); if (error == PGRERROR_TIMEOUT) { // ignore timeout errors, camera may not be responding to // register reads during power-up } else if (error != PGRERROR_OK) { PrintError( error ); return -1; } retries--; } while ((regVal & k_powerVal) == 0 && retries > 0); // Check for timeout errors after retrying if (error == PGRERROR_TIMEOUT) { PrintError( error ); return -1; } regVal = 0,retries = 10; } ///////////////////////////////////////////////////////// // Get the camera information // ///////////////////////////////////////////////////////// CameraInfo camInfo; for(int i = 0; i<numCameras;i++) { error = ppCameras[i]->GetCameraInfo(&camInfo); if (error != PGRERROR_OK) { PrintError( error ); return -1; } PrintCameraInfo(&camInfo); } return 0; }
int main() { BusManager busMgr; unsigned int numCameras = 2; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { std::cout << "Bus Manager error" << std::endl; return false; } PGRGuid guid_L; // error = busMgr.GetCameraFromIndex(1, &guid_L); error = busMgr.GetCameraFromSerialNumber(14481155, &guid_L); if (error != PGRERROR_OK) { std::cout << "Index error" << std::endl; return false; } PGRGuid guid_R; // error = busMgr.GetCameraFromIndex(2, &guid_L); error = busMgr.GetCameraFromSerialNumber(14435551, &guid_R); if (error != PGRERROR_OK) { std::cout << "Index error" << std::endl; return false; } Camera pt_grey_L, pt_grey_R; cv::Mat image_L, image_R; cv::namedWindow("image_L", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); cvMoveWindow("image_L", 3000, 10); cvResizeWindow("image_L",700, 500); cv::namedWindow("image_R", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); cvMoveWindow("image_R", 3000, 10); cvResizeWindow("image_R",700, 500); // connect to camera // init_cam_capture(pt_grey, serialNum); init_cam_capture(pt_grey_L, guid_L); init_cam_capture(pt_grey_R, guid_R); // set camera parameters // set_cam_param(pt_grey); int frame_no = 0; // capture loop char key = 0; while(key != 'q') { // Get the image Image rawImage; error = pt_grey_L.RetrieveBuffer( &rawImage ); if ( error != PGRERROR_OK ) { std::cout << "capture error" << std::endl; return false; } // convert to bgr (default format for OpenCV) Image rgbImage; rawImage.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage ); // convert to OpenCV Mat unsigned int rowBytes = (double)rgbImage.GetReceivedDataSize()/(double)rgbImage.GetRows(); cv::Mat image = cv::Mat(rgbImage.GetRows(), rgbImage.GetCols(), CV_8UC3, rgbImage.GetData(),rowBytes); cv::imshow("image_L", image); key = cv::waitKey(1); // Get the image error = pt_grey_R.RetrieveBuffer( &rawImage ); if ( error != PGRERROR_OK ) { std::cout << "capture error" << std::endl; return false; } // convert to bgr (default format for OpenCV) rawImage.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage ); // convert to OpenCV Mat rowBytes = (double)rgbImage.GetReceivedDataSize()/(double)rgbImage.GetRows(); image = cv::Mat(rgbImage.GetRows(), rgbImage.GetCols(), CV_8UC3, rgbImage.GetData(),rowBytes); cv::imshow("image_R", image); key = cv::waitKey(1); // key = cv::waitKey(50); // if (key == 'c') { // char img_name[50]; // sprintf (img_name, "./frame_%03d.png", frame_no); // // sprintf (img_name, "./images/frame_%03d.png", frame_no); // // sprintf (img_name, "../cam_calib/images/frame_%03d.png", frame_no); // // sprintf (img_name, "../homography2d/images/frame_%03d.png", frame_no); // std::cout << "Writing to " << img_name << std::endl; // cv::imwrite(img_name, image); // frame_no++; // } } error = pt_grey_L.StopCapture(); if (error != PGRERROR_OK) { // PrintError( error ); return false; } error = pt_grey_R.StopCapture(); if (error != PGRERROR_OK) { // PrintError( error ); return false; } pt_grey_L.Disconnect(); pt_grey_R.Disconnect(); }
bool CaptureFlycap::startCapture() { mutex.lock(); cam_id_mutex.lock(); BusManager busMgr; Error error; unsigned int numCameras; int current_id = v_cam_bus->getInt(); if (current_id >= 0) { cam_id = (unsigned int)current_id; } else { fprintf(stderr, "Flycapture: Invalid cam_id: %d\n", current_id); mutex.unlock(); cam_id_mutex.unlock(); return false; } error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { error.PrintErrorTrace(); mutex.unlock(); cam_id_mutex.unlock(); return false; } if(cam_id >= numCameras) { fprintf(stderr, "Flycapture: Invalid cam_id: %u\n", cam_id); mutex.unlock(); cam_id_mutex.unlock(); return false; } bool id_active = false; for (size_t i = 0; i < active_cam_ids.size(); i++) { if (active_cam_ids[i] == cam_id) { id_active = true; break; } } if (id_active) { fprintf(stderr, "Flycapture: cam_id %u is already in use \n", cam_id); mutex.unlock(); cam_id_mutex.unlock(); return false; } camera = new GigECamera(); error = busMgr.GetCameraFromIndex(v_cam_bus->getInt(), &guid); if (error != PGRERROR_OK) { error.PrintErrorTrace(); delete camera; mutex.unlock(); cam_id_mutex.unlock(); return false; } error = camera->Connect(&guid); if (error != PGRERROR_OK) { error.PrintErrorTrace(); delete camera; mutex.unlock(); cam_id_mutex.unlock(); return false; } fprintf(stderr,"Connected"); is_connected = true; CameraInfo camInfo; error = camera->GetCameraInfo(&camInfo); if (error != PGRERROR_OK) { error.PrintErrorTrace(); delete camera; mutex.unlock(); cam_id_mutex.unlock(); return false; } fprintf(stderr," to %s, Serial Number: %u\n", camInfo.modelName, camInfo.serialNumber); Property auto_exposure; auto_exposure.onOff = false; auto_exposure.onePush = false; auto_exposure.type = FlyCapture2::AUTO_EXPOSURE; error = camera->SetProperty(&auto_exposure); if (error != PGRERROR_OK) { mutex.unlock(); cam_id_mutex.unlock(); delete camera; error.PrintErrorTrace(); return false; } writeAllParameterValues(); error = camera->StartCapture(); if (error != PGRERROR_OK) { error.PrintErrorTrace(); delete camera; mutex.unlock(); cam_id_mutex.unlock(); return false; } is_capturing = true; active_cam_ids.push_back(cam_id); mutex.unlock(); cam_id_mutex.unlock(); return true; }
int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); Error error; // Since this application saves images in the current folder // we must ensure that we have permission to write to this folder. // If we do not have permission, fail right away. FILE* tempFile = fopen("test.txt", "w+"); if (tempFile == NULL) { printf("Failed to create file in current folder. Please check permissions.\n"); return -1; } fclose(tempFile); remove("test.txt"); BusManager busMgr; CameraInfo camInfo[10]; unsigned int numCamInfo = 10; error = BusManager::DiscoverGigECameras( camInfo, &numCamInfo ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Number of cameras discovered: %u\n", numCamInfo ); for (unsigned int i=0; i < numCamInfo; i++) { PrintCameraInfo( &camInfo[i] ); } unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } printf( "Number of cameras enumerated: %u\n", numCameras ); for (unsigned int i=0; i < numCameras; i++) { PGRGuid guid; error = busMgr.GetCameraFromIndex(i, &guid); if (error != PGRERROR_OK) { PrintError( error ); return -1; } InterfaceType interfaceType; error = busMgr.GetInterfaceTypeFromGuid( &guid, &interfaceType ); if ( error != PGRERROR_OK ) { PrintError( error ); return -1; } if ( interfaceType == INTERFACE_GIGE ) { RunSingleCamera(guid); } } printf( "Done! Press Enter to exit...\n" ); getchar(); return 0; }
//-------------------------------------------------------------- void ofApp::setup(){ FC2Version fc2Version; //Utilities::GetLibraryVersion( &fc2Version ); ostringstream version; version << "FlyCapture2 library version: " << fc2Version.major << "." << fc2Version.minor << "." << fc2Version.type << "." << fc2Version.build; cout << version.str() << endl; ostringstream timeStamp; timeStamp <<"Application build date: " << __DATE__ << " " << __TIME__; cout << timeStamp.str() << endl << endl; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); } PGRGuid guid; cout << "Number of cameras detected: " << numCameras << endl; for (unsigned int i=0; i < numCameras; i++) { error = busMgr.GetCameraFromIndex(i, &guid); if (error != PGRERROR_OK) { PrintError( error ); } // RunSingleCamera( guid ); } error = cam.Connect(&guid); if (error != PGRERROR_OK) { PrintError( error ); } CameraInfo camInfo; error = cam.GetCameraInfo(&camInfo); if (error != PGRERROR_OK) { PrintError( error ); } error = cam.StartCapture(); if (error != PGRERROR_OK) { PrintError( error ); } error = cam.StopCapture(); error = cam.StartCapture(); }
int main() { PrintBuildInfo(); FILE* arhFile[ ciMaxCameras ]; size_t ardwBytesWritten[ ciMaxCameras ]; const int k_numImages = numberOfImages; Error error; BusManager busMgr; Image image; FC2Config BufferFrame; EmbeddedImageInfo EmbeddedInfo; unsigned int numCameras; int iCountMissedIm = NULL; int iFrameNumberPrev[ ciMaxCameras ]; int iFrameNumberDelta[ ciMaxCameras ]; int iImageSize = NULL; ImageMetadata imFrameCount[ ciMaxCameras ]; FILE* rawFile; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError( error ); return -1; } cout << "Number of cameras detected: " << numCameras << endl << endl; if ( numCameras < 1 ) { cout << "Insufficient number of cameras... press Enter to exit." << endl ; cin.ignore(); return -1; } // Create files to write to if ( createFiles( arhFile, numCameras ) != 0 ) { cout << "There was error creating the files... press Enter to exit."; cin.ignore(); return -1; } Camera** ppCameras = new Camera*[numCameras]; // Connect to all detected cameras and attempt to set them to // the same video mode and frame rate for ( unsigned int uiCamera = 0; uiCamera < numCameras; uiCamera++) { ppCameras[uiCamera] = new Camera(); PGRGuid guid; error = busMgr.GetCameraFromIndex( uiCamera, &guid ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Connect to a camera error = ppCameras[uiCamera]->Connect( &guid ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } // Get the camera information CameraInfo camInfo; error = ppCameras[uiCamera]->GetCameraInfo( &camInfo ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } PrintCameraInfo(&camInfo); // Set video mode and frame rate here!!! error = ppCameras[uiCamera]->SetVideoModeAndFrameRate( VIDEOMODE_640x480Y8, FRAMERATE_30); if (error != PGRERROR_OK) { PrintError( error ); cout << "Error starting cameras." << endl << "This example requires cameras to be able to set to the same video mode and frame rate." << endl << "If your cameras do not support the requested mode, please edit the source code and recompile the application." << endl << "Press Enter to exit." << endl ; cin.ignore(); return -1; } } for ( unsigned int uiCamera = 0; uiCamera < numCameras; uiCamera++) { error = ppCameras[uiCamera]->GetConfiguration(&BufferFrame); if (error != PGRERROR_OK) { PrintError(error); return -1; } BufferFrame.numBuffers = 200; BufferFrame.grabMode = BUFFER_FRAMES; error = ppCameras[uiCamera]->SetConfiguration(&BufferFrame); if (error != PGRERROR_OK) { PrintError(error); return -1; } error = ppCameras[uiCamera]->GetEmbeddedImageInfo(&EmbeddedInfo); if (error != PGRERROR_OK) { PrintError(error); return -1; } if (EmbeddedInfo.timestamp.available == true) { EmbeddedInfo.timestamp.onOff = true; } else { cout << "Timestamp is not available!" << endl; } if (EmbeddedInfo.frameCounter.available == true) { EmbeddedInfo.frameCounter.onOff = true; } else { cout << "Framecounter is not avalable!" << endl; } error = ppCameras[uiCamera]->SetEmbeddedImageInfo(&EmbeddedInfo); if (error != PGRERROR_OK) { PrintError(error); return -1; } error = ppCameras[uiCamera]->StartCapture(); if (error != PGRERROR_OK) { PrintError( error ); cout << "Error starting to capture images." << endl << "Press Enter to exit." << endl ; cin.ignore(); return -1; } } cout << "Grabbing ..." ; // grabbing all images for ( int iImages = 0; iImages < k_numImages; iImages++ ) { // grabbing for all cameras for ( unsigned int uiCamera = 0; uiCamera < numCameras; uiCamera++ ) { error = ppCameras[uiCamera]->RetrieveBuffer( &image ); if (error != PGRERROR_OK) { PrintError( error ); return -1; } //Get the size of the buffer associated with the image, in bytes. Returns the size of the buffer in bytes. iImageSize = image.GetDataSize(); // Write to the file ardwBytesWritten[uiCamera] = fwrite(image.GetData(), 1, image.GetCols()*image.GetRows(), arhFile[uiCamera]); // Ensure that the write was successful if ( ardwBytesWritten[uiCamera] != (unsigned)iImageSize ) { cout << "Error writing to file for camera " << uiCamera << " !" << endl ; return -1; } imFrameCount[uiCamera] = image.GetMetadata(); // Keep track of the difference in image sequence numbers (iFrameCount) // in order to determine if any images have been missed. A difference // greater than 1 indicates that an image has been missed. if( iImages == 0 ) { // This is the first image, set up the variables iFrameNumberPrev[uiCamera] = imFrameCount[uiCamera].embeddedFrameCounter; iFrameNumberDelta[uiCamera] = 1; } else { // Get the difference in sequence numbers between the current // image and the last image we received iFrameNumberDelta[uiCamera] = imFrameCount[uiCamera].embeddedFrameCounter - iFrameNumberPrev[uiCamera]; } if (iFrameNumberDelta[uiCamera] != 1 ) { iCountMissedIm += iFrameNumberDelta[uiCamera] - 1 ; } iFrameNumberPrev[uiCamera] = imFrameCount[uiCamera].embeddedFrameCounter; } } cout << endl; cout << "We missed " << iCountMissedIm << " images!" << endl << endl; // Open file for (unsigned int uiCamera = 0; uiCamera < numCameras; uiCamera++) { string tempFilename = filenames.at(uiCamera); fclose(arhFile[uiCamera]); cout << "Opening " << tempFilename.c_str() << "..." << endl; if ((rawFile = fopen(tempFilename.c_str(), "rb")) == NULL) { cout << "Error opening file: " << tempFilename.c_str() << endl << "Press Enter to exit." << endl;; cin.ignore(); return -1; } cout << "Splitting images" << endl; // Read image into buffer for(int iImages = 0; iImages < k_numImages; iImages++) { string imageFilename; stringstream sstream; if(fread(g_srcBuffer, sizeof(char), iImageSize, rawFile) != iImageSize) { cout << "Error reading image # " << iImages << " from file: " << tempFilename.c_str() << endl << "Press Enter to exit." << endl;; cin.ignore(); return -1; } // Import image into Image structure error = image.SetData(g_srcBuffer, iImageSize); if (error != PGRERROR_OK) { PrintError( error ); return -1; } sstream << csDestinationDirectory << "camera" << uiCamera << "_" << iImages << ".pgm"; sstream >> imageFilename; // Save image to disk error = image.Save(imageFilename.c_str()); if (error != PGRERROR_OK) { PrintError( error ); return -1; } cout << "." ; } cout << endl<< endl; // Close file fclose(rawFile); } for ( unsigned int uiCamera = 0; uiCamera < numCameras; uiCamera++ ) { ppCameras[uiCamera]->StopCapture(); ppCameras[uiCamera]->Disconnect(); delete ppCameras[uiCamera]; } delete [] ppCameras; cout << "Done! Press Enter to exit..." << endl ; cin.ignore(); return 0; }