Plane Gray Disparity Map by StereoSGBM
Hey there,
I am moving my code from python to C++ but run into troubles when computing a disparity map with StereoSGBM
. The map has the same values everywhere -from my python version I do know its not that smooth at all.
Here is some code:
const std::string filename_1 = "i1.png";
const std::string filename_2 = "i2.png";
cv::Mat image_1_grayscale;
cv::cvtColor(cv::imread(filename_1), image_1_grayscale, cv::COLOR_BGR2GRAY);
cv::Mat image_2_grayscale;
cv::cvtColor(cv::imread(filename_2), image_2_grayscale, cv::COLOR_BGR2GRAY);
cv::Ptr<cv::StereoSGBM> sgbm = cv::StereoSGBM::create();
cv::Mat disp;
sgbm->compute(image_1_grayscale, image_2_grayscale, disp);
if (!disp.empty()){
cv::imshow("normal", disp);
cv::waitKey();
cv::destroyAllWindows();
}
I checked size of disp
after computation and it does change to the size of the images, is of type CV_16SC1 and every value is -16.
Whats wrong in this snippet?