Skip to content
Snippets Groups Projects
Commit fdf29e79 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

Enable subpixel accuracy

parent 7da5079c
No related branches found
No related tags found
2 merge requests!9Feature/bilateralfilter,!8Feature/bilateralfilter
Pipeline #10874 canceled
......@@ -26,9 +26,7 @@ void FixstarsSGM::compute(const cv::Mat &l, const cv::Mat &r, cv::Mat &disp) {
if (!ssgm_) {
ssgm_ = new sgm::StereoSGM(l.cols, l.rows, max_disp_, 8, 16,
sgm::EXECUTE_INOUT_HOST2HOST,
// if disparitybilateralfilter used, sub pixel accuracy will be
// truncated in filtering
sgm::StereoSGM::Parameters(10,120,0.95f,!use_filter_));
sgm::StereoSGM::Parameters(10,120,0.95f,true));
}
disp = Mat(cv::Size(l.cols, l.rows), CV_16UC1);
......@@ -41,14 +39,10 @@ void FixstarsSGM::compute(const cv::Mat &l, const cv::Mat &r, cv::Mat &disp) {
// todo: fix libSGM (return float data or provide mask separately)
// disparity values set to (256 << 5) in libSGM consistency check
// (or 256 << 1 without sub-pixel accuracy)
Mat bad_pixels = (disp == (use_filter_ ? (256 << 1) : (256 << 5)));
Mat bad_pixels = (disp == (256 << 5));
disp.setTo(0, bad_pixels);
if (use_filter_) {
// disp /= 16; // sub-pixel accuracy is lost (!!!)
disp.convertTo(disp, CV_8UC1);
cv::cuda::GpuMat l_gpu, disp_gpu, disp_gpu_out;
// parameters need benchmarking, impact of image
// quick tests show with parameters (max_disp_, 25, 3)
......@@ -57,10 +51,7 @@ void FixstarsSGM::compute(const cv::Mat &l, const cv::Mat &r, cv::Mat &disp) {
l_gpu.upload(l);
filter_->apply(disp_gpu, l_gpu, disp_gpu_out);
disp_gpu_out.download(disp);
disp.convertTo(disp, CV_32F);
}
else {
disp.convertTo(disp, CV_32F, 1.0f/16.0f);
}
\ No newline at end of file
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment