Point Grey Research Triclops只读取1帧

时间:2012-10-17 15:53:18

标签: c++ image-processing opencv camera-calibration stereoscopy

我正在使用Point Grey Research BumbleBee 2相机及其SDK。我有这个循环连续抓取帧,但它不起作用。它抓住第一帧ok,但是triclopsGetImage()似乎没有更新refImage(R | L)的内容,因为显示的图像只是从第一帧开始......任何人都有使用Point Grey Cameras或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;
   }

1 个答案:

答案 0 :(得分:1)

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

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

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