I'm trying to get a basic example of StereoBeliefPropagation working. Here is my code:
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/cuda.hpp"
#include "opencv2/cudastereo.hpp"
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
try
{
Mat img1_h = imread("tsukuba1.pgm", 0);
Mat img2_h = imread("tsukuba2.pgm", 0);
cuda::GpuMat img1, img2, disp;
img1.upload(img1_h);
img2.upload(img2_h);
disp.upload(img1_h); // initialize this buffer, will be overwritten
cuda::StereoBeliefPropagation *bp =
cuda::createStereoBeliefPropagation();
bp->compute(img1, img2, disp, cuda::Stream::Null());
Mat disp_h;
disp.download(disp_h);
imshow("Result", disp_h);
waitKey();
}
catch(const cv::Exception& ex)
{
cout << "Error: " << ex.what() << endl;
return 1;
}
return 0;
}
When I run this, I get a segmentation fault at bp->compute
. Does anyone know why? I'm very new to OpenCV on the GPU, so any advice is welcome. Also, links to examples of successfully running any stereo algorithm on the GPU would be great.
I'm using OpenCV version 3.0.0dev from the beginning of April. From what I can tell, it's set up correctly with the GPU (it detects it, and I can copy images on and off). Also, if anyone wants to run this example, the tsukuba images can be found along with the source code on this page.