Hey there,
I am moving my code from python to C++ but run into troubles when computing a disparity map with StereoSGBM
-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()){
printf("%i", disp.cols);
printf("%i", disp.rows);
printf("%d", disp.at<double>(0, 0));
printf("%d", disp.at<double>(1, 1));
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, but with odd values (-983056) written in it.
Whats wrong in this snippet?