From 92b88f971e424e76b83eb10de3fd71e93764cfca Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Tue, 1 Sep 2020 08:47:47 +0300
Subject: [PATCH] Increase disparity threshold

---
 components/operators/src/disparity/fixstars_sgm.cpp | 4 ++--
 lib/libsgm/src/check_consistency.cu                 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/components/operators/src/disparity/fixstars_sgm.cpp b/components/operators/src/disparity/fixstars_sgm.cpp
index 6f0599ec4..81b1b9083 100644
--- a/components/operators/src/disparity/fixstars_sgm.cpp
+++ b/components/operators/src/disparity/fixstars_sgm.cpp
@@ -62,7 +62,7 @@ FixstarsSGM::FixstarsSGM(ftl::operators::Graph *g, ftl::Configurable* cfg) :
 	uniqueness_ = cfg->value("uniqueness", 0.95f);
 	P1_ = cfg->value("P1", 10);
 	P2_ = cfg->value("P2", 120);
-	max_disp_ = cfg->value("max_disp", 256);
+	max_disp_ = cfg->value("num_disp", 256);
 
 	if (uniqueness_ < 0.0 || uniqueness_ > 1.0) {
 		uniqueness_ = 1.0;
@@ -228,7 +228,7 @@ bool FixstarsSGM::apply(Frame &in, Frame &out, cudaStream_t stream) {
 		ftl::cuda::merge_disparities(disp_int_, disp, stream);
 	}
 
-	cv::cuda::threshold(disp_int_, disp, 4096.0f, 0.0f, cv::THRESH_TOZERO_INV, cvstream);
+	cv::cuda::threshold(disp_int_, disp, 16383.0f, 0.0f, cv::THRESH_TOZERO_INV, cvstream);
 
 	if (config()->value("check_reprojection", false)) {
 		ftl::cuda::check_reprojection(disp, in.getTexture<uchar4>(Channel::Colour),
diff --git a/lib/libsgm/src/check_consistency.cu b/lib/libsgm/src/check_consistency.cu
index 97cf953b3..dde4f5f29 100644
--- a/lib/libsgm/src/check_consistency.cu
+++ b/lib/libsgm/src/check_consistency.cu
@@ -37,7 +37,7 @@ namespace {
 			int diff = abs(d_rightDisp[i * dst_pitch + k] - d);
 			if (mask != 0 || diff > 1) {
 				// masked or left-right inconsistent pixel -> invalid
-				dout = (256 << (sgm::StereoSGM::SUBPIXEL_SHIFT+1));
+				dout = (1024 << (sgm::StereoSGM::SUBPIXEL_SHIFT));
 			}
 		}
 		d_leftDisp[i * dst_pitch + j] = dout;
-- 
GitLab