From 34b84ab4b2527b95e8ee97a367ea5b9ef92df947 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 30 Oct 2019 17:57:18 +0200
Subject: [PATCH] Add options to config

---
 applications/reconstruct/src/filters/smoothing.cu | 14 +++++++-------
 applications/reconstruct/src/main.cpp             |  9 +++++----
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/applications/reconstruct/src/filters/smoothing.cu b/applications/reconstruct/src/filters/smoothing.cu
index 9ea08594c..21f30cafd 100644
--- a/applications/reconstruct/src/filters/smoothing.cu
+++ b/applications/reconstruct/src/filters/smoothing.cu
@@ -27,15 +27,15 @@ __global__ void depth_smooth_kernel(
 		float contrib = 0.0f;
 		float new_depth = 0.0f;
 
-		for (int u=-RADIUS; u<=RADIUS; ++u) {
-			for (int v=-RADIUS; v<=RADIUS; ++v) {
+		for (int v=-RADIUS; v<=RADIUS; ++v) {
+			for (int u=-RADIUS; u<=RADIUS; ++u) {
 				// Get colour difference to center
-				uchar4 cN = colour_in.tex2D((int)x+u, (int)y+v);
-				float colourWeight = ftl::cuda::colourWeighting(c, cN, thresh);
-				float dN = depth_in.tex2D((int)x + u, (int)y + v);
-				float3 posN = camera.screenToCam(x+u, y+v, dN);
+				const uchar4 cN = colour_in.tex2D((int)x+u, (int)y+v);
+				const float colourWeight = ftl::cuda::colourWeighting(c, cN, thresh);
+				const float dN = depth_in.tex2D((int)x + u, (int)y + v);
+				const float3 posN = camera.screenToCam(x+u, y+v, dN);
+				const float weight = ftl::cuda::spatialWeighting(posN, pos, factor * colourWeight);
 				
-				float weight = ftl::cuda::spatialWeighting(posN, pos, factor * colourWeight);
 				contrib += weight;
 				new_depth += dN * weight;
 			}
diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp
index f3272e0d9..e6a7d2d8b 100644
--- a/applications/reconstruct/src/main.cpp
+++ b/applications/reconstruct/src/main.cpp
@@ -272,10 +272,11 @@ static void run(ftl::Configurable *root) {
 			UNIQUE_LOCK(scene_A.mtx, lk);
 
 			cv::cuda::GpuMat tmp;
-			float factor = filter->value("smooth_factor", 0.04f);
-			float colour_limit = filter->value("colour_limit", 50.0f);
+			float factor = filter->value("smooth_factor", 0.4f);
+			float colour_limit = filter->value("colour_limit", 30.0f);
 			bool do_smooth = filter->value("pre_smooth", false);
-			int iters = filter->value("iterations", 1);
+			int iters = filter->value("iterations", 3);
+			int radius = filter->value("radius", 5);
 
 			if (do_smooth) {
 				// Presmooth...
@@ -298,7 +299,7 @@ static void run(ftl::Configurable *root) {
 						f.createTexture<uchar4>(Channel::Colour),
 						f.createTexture<float>(Channel::Depth2, ftl::rgbd::Format<float>(f.get<cv::cuda::GpuMat>(Channel::Depth).size())),
 						s->parameters(),
-						1, factor, colour_limit, iters, 0
+						radius, factor, colour_limit, iters, 0
 					);
 				}
 			}
-- 
GitLab