From a7d339f4e3f159c553e7bf2cd0292982cf39bdeb Mon Sep 17 00:00:00 2001
From: Sebastian Hahta <joseha@utu.fi>
Date: Mon, 20 Apr 2020 13:39:05 +0300
Subject: [PATCH] fix build

---
 components/operators/src/depth.cpp    |  3 +++
 lib/libstereo/src/stereo_censussgm.cu | 14 +++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/components/operators/src/depth.cpp b/components/operators/src/depth.cpp
index 2c689c2b4..24597a233 100644
--- a/components/operators/src/depth.cpp
+++ b/components/operators/src/depth.cpp
@@ -147,8 +147,11 @@ void DepthChannel::_createPipeline(size_t size) {
 	#ifdef HAVE_LIBSGM
 	pipe_->append<ftl::operators::FixstarsSGM>("algorithm");
 	#else
+	// TODO fix windows build
+	#ifndef _MSC_VER
 	pipe_->append<ftl::operators::StereoDisparity>("algorithm");
 	#endif
+	#endif
 	pipe_->append<ftl::operators::DisparityBilateralFilter>("bilateral_filter");
 	//pipe_->append<ftl::operators::OpticalFlowTemporalSmoothing>("optflow_filter", Channel::Disparity);
 	pipe_->append<ftl::operators::DisparityToDepth>("calculate_depth");
diff --git a/lib/libstereo/src/stereo_censussgm.cu b/lib/libstereo/src/stereo_censussgm.cu
index ec96e7d64..d707e7846 100644
--- a/lib/libstereo/src/stereo_censussgm.cu
+++ b/lib/libstereo/src/stereo_censussgm.cu
@@ -53,20 +53,18 @@ struct StereoCensusSgm::Impl {
 	//DisparitySpaceImage<unsigned short> dsi;
 	CensusMatchingCost cost;
 	Array2D<unsigned short> cost_min_paths;
-	Array2D<float> confidence;
+	Array2D<unsigned short> uncertainty;
 	Array2D<float> disparity_r;
 	Array2D<uchar> l;
 	Array2D<uchar> r;
 
-	cv::Mat uncertainty;
-
 	PathAggregator<StandardSGM<CensusMatchingCost::DataType>> aggr;
 	WinnerTakesAll<DSImage16U,float> wta;
 
 	Impl(int width, int height, int min_disp, int max_disp) :
 		cost(width, height, min_disp, max_disp),
 		cost_min_paths(width, height),
-		confidence(width, height),
+		uncertainty(width, height),
 		disparity_r(width, height), l(width, height), r(width, height) {}
 
 };
@@ -111,14 +109,16 @@ void StereoCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArra
 	// Bioinformatics). https://doi.org/10.1007/978-3-319-11752-2_4
 
 	if (disparity.isGpuMat()) {
-		cv::cuda::subtract(impl_->wta.min_cost.toGpuMat(), impl_->cost_min_paths.toGpuMat(), impl_->uncertainty);
+		auto uncertainty = impl_->uncertainty.toGpuMat();
+		cv::cuda::subtract(impl_->wta.min_cost.toGpuMat(), impl_->cost_min_paths.toGpuMat(), uncertainty);
 		cv::cuda::compare(uncertainty, params.uniqueness, uncertainty, cv::CMP_GT);
 		impl_->wta.disparity.toGpuMat().setTo(0, uncertainty);
 	}
 	else {
-		cv::subtract(impl_->wta.min_cost.toMat(), impl_->cost_min_paths.toMat(), impl_->uncertainty);
+		auto uncertainty = impl_->uncertainty.toMat();
+		cv::subtract(impl_->wta.min_cost.toMat(), impl_->cost_min_paths.toMat(), uncertainty);
 		cv::compare(uncertainty, params.uniqueness, uncertainty, cv::CMP_GT);
-		impl_->wta.disparity.toMat().setTo(0, uncertainty);
+		impl_->wta.disparity.toGpuMat().setTo(0, uncertainty);
 	}
 
 	median_filter(impl_->wta.disparity, disparity);
-- 
GitLab