Ask Your Question

hunse's profile - activity

2014-07-04 10:17:18 -0600 received badge  Self-Learner (source)
2014-07-03 13:41:39 -0600 received badge  Editor (source)
2014-07-03 13:40:12 -0600 answered a question Segmentation fault in StereoBeliefPropagation

I found the problem. The line

cuda::StereoBeliefPropagation *bp =
    cuda::createStereoBeliefPropagation();

should instead be

Ptr<cuda::StereoBeliefPropagation> bp =
    cuda::createStereoBeliefPropagation();

As a note, the OpenCV GPU examples were very useful in solving this problem.

2014-06-26 13:20:58 -0600 commented question using opencv gpu functions in python

As far as I know, there is not. I've been using OpenCV 3 in Python for a while now, but I had to switch to C++ to get at the CUDA functions. There is no Python API documentation for the CUDA functions, and the fact that cv2.cpp (the file that defines the Python API) doesn't import any of the CUDA-related headers further suggests to me that these functions are not available in Python.

2014-06-25 11:54:45 -0600 received badge  Student (source)
2014-06-25 11:28:57 -0600 asked a question Segmentation fault in StereoBeliefPropagation

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.