Skip to content

Commit

Permalink
StereoBM/StereoSGBM: Thresholding output to zero when minDisparity is…
Browse files Browse the repository at this point in the history
… used
  • Loading branch information
matlabbe committed Sep 17, 2023
1 parent 0b7181f commit fb466a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions corelib/src/stereo/StereoBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ cv::Mat StereoBM::computeDisparity(
stereo->setDisp12MaxDiff(disp12MaxDiff_);
stereo->compute(leftMono, rightImage, disparity);
#endif

if(minDisparity_>0)
{
cv::Mat dst;
cv::threshold(disparity, dst, minDisparity_*16, 0, cv::THRESH_TOZERO);
disparity = dst;
}

return disparity;
}

Expand Down
8 changes: 8 additions & 0 deletions corelib/src/stereo/StereoSGBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ cv::Mat StereoSGBM::computeDisparity(
mode_);
stereo->compute(leftMono, rightImage, disparity);
#endif

if(minDisparity_>0)
{
cv::Mat dst;
cv::threshold(disparity, dst, minDisparity_*16, 0, cv::THRESH_TOZERO);
disparity = dst;
}

return disparity;
}

Expand Down

0 comments on commit fb466a6

Please sign in to comment.