2

还是完全依赖于 Bumblebee(或任何其他点灰色成像传感器)?我正在尝试链接 Bumblebee 2 立体设备附带的立体处理 API 来处理一些离线图像。看来,triclops 立体函数需要一些上下文标志和校准文件,格式为 input.cal 和 input.ppm(即包含两个立体校正图像的一张图像以某种方式模糊和重叠)。如何从其他离线图像中获取此 input.ppm 文件以仍然能够使用 triclops stereo API。校准文件input.cal怎么样,能不能得到与离线图像一致的,如何得到?

4

1 回答 1

2

是的,Triclops API 可用于处理离线图像。您指出的要求是来自相机和图像文件的校准文件(.cal)。校准文件最好在图像捕获时提取,但根据我的经验,除非您更改设置,否则它始终保持不变。为了满足 Triclops API 的输入,您还需要使用 Point Gray Fly Capture API,因为它提供了图像转换的方法。我的项目正在做你所要求的所有事情。我在现场捕捉原始像素交错图像,然后使用 FlyCapture 和 Triclops API 处理它们,以创建校正和视差图像以及来自立体对的点云。

查看 Point Grey 样本及其 API 文档,了解如何获取校准文件。本质上,方法是这样flycaptureGetCalibrationFileFromCamera( context, &szCalFile ); 的:上下文是“相机上下文”

您的初始图像文件格式将改变转换方法,但在我的例子中,这是我使用 C++ 从原始到立体声的转换。我正在使用 Bumblebee XB3 彩色相机,原始图像大小为 1280x960,并从外部两个相机抓取图像:

   // Read raw file 
   //pFile = fopen ( "FlyCap.raw" , "rb" );
   pFile = fopen ( argv[1] , "rb" );
   if (pFile==NULL) {fputs ("File error",stderr); exit (1);}

   // Set raw file size 
   ISize = (numCols*numRows*bytesPerPixel);

   // allocate memory to contain the whole file:
   buffer = (unsigned char*) malloc (sizeof(char)*ISize);
   if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}

   // copy the file into the buffer:
   result = fread (buffer,1,ISize,pFile);
   if (result != ISize) {fputs ("Reading error",stderr); exit (3);}

   // Create the FlyCapture Context for processing
   fe = flycaptureCreateContext( &flycapture );
   _HANDLE_FLYCAPTURE_ERROR( "flycaptureCreateContext()", fe );

   fe = flycaptureSetColorProcessingMethod(flycapture, FLYCAPTURE_HQLINEAR);
   _HANDLE_FLYCAPTURE_ERROR( "flycaptureSetColorProcessingMethod()", fe );

   fe = flycaptureSetColorTileFormat(flycapture, FLYCAPTURE_STIPPLEDFORMAT_GBRG);
   _HANDLE_FLYCAPTURE_ERROR( "flycaptureSetColorTileFormat()", fe );

   //Import the raw image in buffer into FlyCaptureImage structure
   flycaptureImage.iCols = 1280;
   flycaptureImage.iRows = 960;
   flycaptureImage.iNumImages = 2;
   flycaptureImage.bStippled = true;
   flycaptureImage.pixelFormat = FLYCAPTURE_RAW16;   
   flycaptureImage.iRowInc = 2560;
   flycaptureImage.timeStamp.ulSeconds = 100;
   flycaptureImage.timeStamp.ulMicroSeconds = 100;
   flycaptureImage.pData = buffer;

   // Create buffers for holding the color and mono images
   unsigned char* rowIntColor = 
   new unsigned char[ numCols * numRows * flycaptureImage.iNumImages * 4 ];
   unsigned char* rowIntMono = 
   new unsigned char[ numCols * numRows * flycaptureImage.iNumImages ];

   // Create a temporary FlyCaptureImage for preparing the stereo image
   FlyCaptureImage tempColorImage;
   FlyCaptureImage tempMonoImage;

   tempColorImage.pData = rowIntColor;
   tempMonoImage.pData = rowIntMono;


   // Convert the pixel interleaved raw data to row interleaved format
   fe = flycapturePrepareStereoImage( flycapture, flycaptureImage, &tempMonoImage,   &tempColorImage  );
   _HANDLE_FLYCAPTURE_ERROR( "flycapturePrepareStereoImage()", fe );

   //Save side-by-side color stereo image
   fe = flycaptureSaveImage( flycapture, &tempColorImage, stereoimg, FLYCAPTURE_FILEFORMAT_PPM );
   _HANDLE_FLYCAPTURE_ERROR( "flycaptureSaveImage()", fe );  

   printf ("Saving Stereo...\n");

请注意,到目前为止,我根本没有使用 Triclops API。的输出flycaptureSaveImage();是输入 Triclops 方法的内容。那时有一些选项可以处理彩色与单色。看一下他们的 Triclops API 附带的 Point Grey 示例,称为“stereoto3dpoints.cpp”,它从我离开的地方接管。我希望这能够帮到你。

于 2012-09-14T12:43:20.817 回答