diff --git a/applications/reconstruct/src/filters/smoothing.cu b/applications/reconstruct/src/filters/smoothing.cu index 9ea08594c8a5bebf6a10276279e00ef9dd28f257..21f30cafda69682e15c987b692a8f712e4373d7d 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 f3272e0d952eadd841587f6f668724ac06cc9f0d..e6a7d2d8b3e7f39bb47bbd3b43b4cd3ce166db38 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 ); } }