Ask Your Question
0

StereoSGBM crash

asked 2016-08-18 11:57:30 -0600

Nbb gravatar image

updated 2016-08-22 10:11:34 -0600

The code crashes at stereo->compute without any mention of error. Any ideas why ?

Ptr<StereoSGBM> stereo;
int window = 5;
stereo->create(1, 100, 16, 8 * 3 * window*window, 32 * 3 * window*window, 1, 10, 100, 32);

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

stereo->compute(imgL, imgR, disp);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-08-23 19:57:40 -0600

updated 2016-08-23 20:01:18 -0600

cv::stereo::StereoBinarySGBM::create returns a cv::Ptr. It is a static function and usually for clarity and sanity one calls these not from an object, but 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 ) );

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

sgbm->compute(imgL, imgR, disp);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-18 11:57:30 -0600

Seen: 860 times

Last updated: Aug 23 '16