gpt4 book ai didi

c++ - Point Grey Research Triclops 只读取 1 帧

转载 作者:太空宇宙 更新时间:2023-11-03 23:02:49 25 4
gpt4 key购买 nike

我使用的是 Point Grey Research BumbleBee 2 相机及其 SDK。我有这个循环来连续抓取帧,但它不起作用。它捕获了第一帧,但 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 保留了数据但没有更新,要么是三叶草有问题。

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;
}

最佳答案

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

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

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

关于c++ - Point Grey Research Triclops 只读取 1 帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12938326/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com