2012-10-17 20 views
1

我正在使用Point Grey Research BumbleBee 2相机及其SDK。我有这个循环来连续抓帧,但它不起作用。它抓住第一帧确定,但triclopsGetImage()似乎并没有更新refImage(R | L)的内容,因为所显示的图像仅仅是第一帧...任何人都有使用Point Gray相机或triclops SDK的经验?Point Grey Research Triclops只能读取1帧

//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; 
    } 
+0

什么是'triclopsGetImage'返回? –

+0

te从triclops返回teImage报告一个0,表示它工作正常。标记错误的非零值。 – Oliver9523

回答

1

如果你看一下在Triclops SDK文件夹的例子就说明他们的计划获得图像之前调用以下方法:

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

您可能需要在循环结束时调用这些函数以通知相机计算下一帧的差异。