From 67d61406fe5ed74818bc4687cc4d3d4d75d47269 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 20 Feb 2020 13:24:31 +0200
Subject: [PATCH] Remove discon before mvmls

---
 applications/gui/src/src_window.cpp                     | 2 +-
 components/operators/src/fusion/correspondence_depth.cu | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/applications/gui/src/src_window.cpp b/applications/gui/src/src_window.cpp
index 556d1f794..ea49a76eb 100644
--- a/applications/gui/src/src_window.cpp
+++ b/applications/gui/src/src_window.cpp
@@ -227,8 +227,8 @@ void SourceWindow::_checkFrameSets(int id) {
 		p->append<ftl::operators::CullWeight>("remove_weights")->value("enabled", false);
 		p->append<ftl::operators::DegradeWeight>("degrade");
 		p->append<ftl::operators::VisCrossSupport>("viscross")->set("enabled", false);
-		p->append<ftl::operators::MultiViewMLS>("mvmls")->value("enabled", false);
 		p->append<ftl::operators::CullDiscontinuity>("remove_discontinuity");
+		p->append<ftl::operators::MultiViewMLS>("mvmls")->value("enabled", false);
 
 		pre_pipelines_.push_back(p);
 		framesets_.push_back(new ftl::rgbd::FrameSet);
diff --git a/components/operators/src/fusion/correspondence_depth.cu b/components/operators/src/fusion/correspondence_depth.cu
index 412c25d32..9f83fa79f 100644
--- a/components/operators/src/fusion/correspondence_depth.cu
+++ b/components/operators/src/fusion/correspondence_depth.cu
@@ -86,7 +86,7 @@ __global__ void corresponding_depth_kernel(
 
 			// Sum all squared distance errors in a 4x4 pixel neighborhood
 			float wcost = ftl::cuda::halfWarpSum(cost) / 16.0f;
-			cost = (wcost + cost) / 2.0f;  // Enables per pixel adjustments
+			cost = (wcost < 1.0f) ? (wcost + cost) / 2.0f : 1.0f;  // Enables per pixel adjustments
 
 			// Record the best result
             bestStep = (cost < bestcost) ? i : bestStep;
@@ -100,7 +100,11 @@ __global__ void corresponding_depth_kernel(
             linePos.y += lineM;
         }
 
-        float bestadjust = float(bestStep-(COR_STEPS/2))*depthM;
+		float bestadjust = float(bestStep-(COR_STEPS/2))*depthM;
+		
+		//if (bestStep == 0 ||bestStep == COR_STEPS-1) {
+		//	printf("Bad step: %f\n", bestcost);
+		//}
 
         // Detect matches to boundaries, and discard those
         uint stepMask = 1 << bestStep;
-- 
GitLab