Ask Your Question

Revision history [back]

create returns a cv::Ptr. It is a static function and usually for clarity and sanity one calls these not from an object, but from the class. In your case stereo is a nullptr and so you are getting a segfault.

The following is correct:

auto sgbm = cv::stereo::StereoBinarySGBM::create( 0, //mindisp NDISP_DEFAULT, //numdisp 9, //BlockSize 25, //P1 50, //P2 1, //dispdiffmax 63, //prefiltercap 40, //uniqueness 200, //speckle window size 2, //speckle range cv::StereoSGBM::MODE_SGBM ) );

Mat imgL = imread("L.png", CV_LOAD_IMAGE_GRAYSCALE); Mat imgR = imread("R.png", CV_LOAD_IMAGE_GRAYSCALE); Mat disp;

sgbm->compute(imgL, imgR, disp);

create returns a cv::Ptr. It is a static function and usually for clarity and sanity one calls these not from an object, but from the class. In your case stereo is a nullptr and so you are getting a segfault.

The following is correct:

auto sgbm = cv::stereo::StereoBinarySGBM::create(    0,   //mindisp
                                                           NDISP_DEFAULT, //numdisp
                                                           9,   //BlockSize
                                                          25,   //P1
                                                          50,   //P2
                                                           1,   //dispdiffmax
                                                          63,   //prefiltercap
                                                          40,   //uniqueness
                                                         200,   //speckle window size
                                                           2,   //speckle range
                                                           cv::StereoSGBM::MODE_SGBM ) );

);

Mat imgL = imread("L.png", CV_LOAD_IMAGE_GRAYSCALE); Mat imgR = imread("R.png", CV_LOAD_IMAGE_GRAYSCALE); Mat disp;

disp;

sgbm->compute(imgL, imgR, disp);

disp);

create cv::stereo::StereoBinarySGBM::create returns a cv::Ptr. cv::Ptr. It is a static function and usually for clarity and sanity one calls these not from an object, but from with the class. In your case stereo is a nullptr and so you are getting a segfault.

The following is correct:

auto sgbm = cv::stereo::StereoBinarySGBM::create(    0,   //mindisp
                                                      NDISP_DEFAULT, //numdisp
                                                      9,   //BlockSize
                                                     25,   //P1
                                                     50,   //P2
                                                      1,   //dispdiffmax
                                                     63,   //prefiltercap
                                                     40,   //uniqueness
                                                    200,   //speckle window size
                                                      2,   //speckle range
                                                      cv::StereoSGBM::MODE_SGBM ) );

Mat cv::Mat imgL = imread("L.png", cv::imread("L.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat cv::Mat imgR = imread("R.png", cv::imread("R.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat cv::Mat disp;

sgbm->compute(imgL, imgR, disp);