Skip to content
Snippets Groups Projects
Commit d9b954be authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Iterate the MLS

parent 9baa4a5c
No related branches found
No related tags found
1 merge request!158Implements #228 adaptive MLS and smoothing channel
Pipeline #16126 passed
This commit is part of merge request !158. Comments created here will be created in the context of that merge request.
...@@ -71,7 +71,11 @@ void MLSSmoother::smooth(ftl::rgbd::Frame &f, ftl::rgbd::Source *s) { ...@@ -71,7 +71,11 @@ void MLSSmoother::smooth(ftl::rgbd::Frame &f, ftl::rgbd::Source *s) {
bool do_smooth = value("mls_smooth", false); bool do_smooth = value("mls_smooth", false);
if (!do_smooth) return; if (!do_smooth) return;
if (!f.hasChannel(Channel::Normals)) { float thresh = value("mls_threshold", 0.04f);
int iters = value("mls_iterations", 1);
for (int i=0; i<iters; ++i) {
if (i > 0 || !f.hasChannel(Channel::Normals)) {
ftl::cuda::normals( ftl::cuda::normals(
f.createTexture<float4>(Channel::Normals, ftl::rgbd::Format<float4>(f.get<cv::cuda::GpuMat>(Channel::Depth).size())), f.createTexture<float4>(Channel::Normals, ftl::rgbd::Format<float4>(f.get<cv::cuda::GpuMat>(Channel::Depth).size())),
f.createTexture<float>(Channel::Depth), f.createTexture<float>(Channel::Depth),
...@@ -79,7 +83,6 @@ void MLSSmoother::smooth(ftl::rgbd::Frame &f, ftl::rgbd::Source *s) { ...@@ -79,7 +83,6 @@ void MLSSmoother::smooth(ftl::rgbd::Frame &f, ftl::rgbd::Source *s) {
); );
} }
float thresh = value("mls_threshold", 0.04f);
ftl::cuda::mls_smooth( ftl::cuda::mls_smooth(
f.createTexture<float4>(Channel::Normals), f.createTexture<float4>(Channel::Normals),
f.createTexture<float>(Channel::Depth), f.createTexture<float>(Channel::Depth),
...@@ -91,4 +94,5 @@ void MLSSmoother::smooth(ftl::rgbd::Frame &f, ftl::rgbd::Source *s) { ...@@ -91,4 +94,5 @@ void MLSSmoother::smooth(ftl::rgbd::Frame &f, ftl::rgbd::Source *s) {
f.swapChannels(Channel::Depth, Channel::Depth2); f.swapChannels(Channel::Depth, Channel::Depth2);
} }
}
...@@ -79,7 +79,7 @@ void ftl::cuda::mls_smooth( ...@@ -79,7 +79,7 @@ void ftl::cuda::mls_smooth(
const dim3 gridSize((depth_out.width() + T_PER_BLOCK - 1)/T_PER_BLOCK, (depth_out.height() + T_PER_BLOCK - 1)/T_PER_BLOCK); const dim3 gridSize((depth_out.width() + T_PER_BLOCK - 1)/T_PER_BLOCK, (depth_out.height() + T_PER_BLOCK - 1)/T_PER_BLOCK);
const dim3 blockSize(T_PER_BLOCK, T_PER_BLOCK); const dim3 blockSize(T_PER_BLOCK, T_PER_BLOCK);
mls_smooth_kernel<3><<<gridSize, blockSize, 0, stream>>>(normals, depth_in, depth_out, smoothing, camera); mls_smooth_kernel<2><<<gridSize, blockSize, 0, stream>>>(normals, depth_in, depth_out, smoothing, camera);
cudaSafeCall( cudaGetLastError() ); cudaSafeCall( cudaGetLastError() );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment