1

我正在使用 Point Gray Research BumbleBee 2 相机和他们的 SDK。我有这个循环来连续抓取帧,但它不起作用。它可以抓取第一帧,但 triclopsGetImage() 似乎没有更新 refImage(R|L) 的内容,因为显示的图像只是来自第一帧......任何人都有点灰色相机或 triclops SDK 的经验?

   //There's more code above

   int nframes = 20;
   for (int frame = 0; frame < nframes ; frame++ ) {

       te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_RIGHT, &refImageR );
       te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_LEFT, &refImageL );

       cv::Mat leftIm(cv::Mat::zeros(refImageR.nrows,refImageR.ncols,CV_8UC1));
       cv::Mat rightIm(cv::Mat::zeros(refImageR.nrows,refImageR.ncols,CV_8UC1));
       int counter = 0;
       for (int row=0;row<refImageR.nrows;row++) {
           for (int col=0;col<refImageR.ncols;col++) {
               leftIm.at<uchar>(row,col) = refImageL.data[counter];
               rightIm.at<uchar>(row,col) = refImageR.data[counter];
               counter++;
           }
       }

       imshow("LeftIm",leftIm);
       imshow("RightIm",rightIm);

       cv::waitKey(1000);
       cout << "frame = " << frame << endl;
   }

编辑

好的,这无论如何都不优雅,但我认为它有帮助。即使这样做,我也只能得到第一帧的内容。我在想 cv::Mat leftIm 和 rightIm 都在保留数据并且没有更新,或者 triclops 有问题。

TriclopsContext triclops;

从头文件中可以看出“TriclopsContext 是一个指向内部结构的指针,该结构维护 Triclops 库所需的所有图像和簿记信息。它是所有参数的容器”

for (int frame = 1; frame < nframes ; frame++ ) {

       if (frame == 1) {
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_RIGHT, &refImageR1 );
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_LEFT, &refImageL1 );
       } else if (frame == 2) {
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_RIGHT, &refImageR2 );
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_LEFT, &refImageL2 );
       } else if (frame == 3) {
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_RIGHT, &refImageR3 );
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_LEFT, &refImageL3 );
       } else if (frame == 4) {
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_RIGHT, &refImageR4 );
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_LEFT, &refImageL4 );
       } else if (frame == 5) {
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_RIGHT, &refImageR5 );
            te = triclopsGetImage( triclops, TriImg_RECTIFIED, TriCam_LEFT, &refImageL5 );
       }

       cv::Mat leftIm(cv::Mat::zeros(refImageR1.nrows,refImageR1.ncols,CV_8UC1));
       cv::Mat rightIm(cv::Mat::zeros(refImageR1.nrows,refImageR1.ncols,CV_8UC1));
       int counter = 0;
       for (int row=0;row<refImageR1.nrows;row++) {
           for (int col=0;col<refImageR1.ncols;col++) {
               //leftIm.at<uchar>(row,col) = refImageL.data[counter];
               //rightIm.at<uchar>(row,col) = refImageR.data[counter];
               if (frame == 1) {
                    leftIm.at<uchar>(row,col) = refImageL1.data[counter];
                    rightIm.at<uchar>(row,col) = refImageR1.data[counter];
               } else if (frame == 2) {
                    leftIm.at<uchar>(row,col) = refImageL2.data[counter];
                    rightIm.at<uchar>(row,col) = refImageR2.data[counter];
               } else if (frame == 3) {
                    leftIm.at<uchar>(row,col) = refImageL3.data[counter];
                    rightIm.at<uchar>(row,col) = refImageR3.data[counter];
               } else if (frame == 4) {
                    leftIm.at<uchar>(row,col) = refImageL4.data[counter];
                    rightIm.at<uchar>(row,col) = refImageR4.data[counter];
               } else if (frame == 5) {
                    leftIm.at<uchar>(row,col) = refImageL5.data[counter];
                    rightIm.at<uchar>(row,col) = refImageR5.data[counter];
               }

               counter++;
           }
       }

       imshow("LeftIm",leftIm);
       imshow("RightIm",rightIm);

       cv::waitKey(1000);
       cout << "frame = " << frame << endl;
   }
4

1 回答 1

1

如果您查看 Triclops SDK 文件夹中的示例,它会显示他们的程序在获取图像之前调用以下方法:

error = triclopsPreprocess( context, &inputData );
error = triclopsStereo( context );

您可能需要在循环结束时调用它们来告诉相机计算下一帧的视差。

于 2012-10-25T14:50:03.360 回答