diff --git a/components/operators/include/ftl/operators/smoothing.hpp b/components/operators/include/ftl/operators/smoothing.hpp index 1f6961d812916bf8f9ecaa5c4e7629947230c0ac..b5362ea6f1a6c16de81cdb7c55339058476da09d 100644 --- a/components/operators/include/ftl/operators/smoothing.hpp +++ b/components/operators/include/ftl/operators/smoothing.hpp @@ -43,7 +43,7 @@ class SmoothChannel : public ftl::operators::Operator { bool apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd::Source *src, cudaStream_t stream) override; private: - ftl::rgbd::Frame temp_[2]; + ftl::rgbd::Frame temp_[6]; }; /** diff --git a/components/operators/src/smoothing.cpp b/components/operators/src/smoothing.cpp index 79f37207756af7977d66c4c11d86c557ddd884c1..61dd9f8ce24fa26dea6854d271c56eb284a4e630 100644 --- a/components/operators/src/smoothing.cpp +++ b/components/operators/src/smoothing.cpp @@ -71,8 +71,9 @@ SmoothChannel::~SmoothChannel() { } bool SmoothChannel::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd::Source *s, cudaStream_t stream) { - int radius = config()->value("radius", 1); + int radius = config()->value("radius", 3); float threshold = config()->value("threshold", 30.0f); + int iters = max(0, min(6, config()->value("levels", 4))); int width = s->parameters().width; int height = s->parameters().height; @@ -91,24 +92,26 @@ bool SmoothChannel::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd stream ); - width /= 2; - height /= 2; + for (int i=0; i<iters; ++i) { + width /= 2; + height /= 2; - ftl::rgbd::Camera scaledCam = s->parameters().scaled(width, height); + ftl::rgbd::Camera scaledCam = s->parameters().scaled(width, height); - // Downscale images for next pass - cv::cuda::resize(in.get<GpuMat>(Channel::Colour), temp_[0].create<GpuMat>(Channel::Colour), cv::Size(width, height), 0.0, 0.0, cv::INTER_LINEAR); - cv::cuda::resize(in.get<GpuMat>(Channel::Depth), temp_[0].create<GpuMat>(Channel::Depth), cv::Size(width, height), 0.0, 0.0, cv::INTER_NEAREST); + // Downscale images for next pass + cv::cuda::resize(in.get<GpuMat>(Channel::Colour), temp_[i].create<GpuMat>(Channel::Colour), cv::Size(width, height), 0.0, 0.0, cv::INTER_LINEAR); + cv::cuda::resize(in.get<GpuMat>(Channel::Depth), temp_[i].create<GpuMat>(Channel::Depth), cv::Size(width, height), 0.0, 0.0, cv::INTER_NEAREST); - ftl::cuda::smooth_channel( - temp_[0].createTexture<uchar4>(Channel::Colour), - temp_[0].createTexture<float>(Channel::Depth), - out.getTexture<float>(Channel::Smoothing), - scaledCam, - threshold, - radius, - stream - ); + ftl::cuda::smooth_channel( + temp_[i].createTexture<uchar4>(Channel::Colour), + temp_[i].createTexture<float>(Channel::Depth), + out.getTexture<float>(Channel::Smoothing), + scaledCam, + threshold, + radius, + stream + ); + } return true; } diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp index 24629e13929983cbaeb1e13af31e68745d02f28b..b0ee77a449e33b82641c18aa0c7a039ed42e8626 100644 --- a/components/rgbd-sources/src/source.cpp +++ b/components/rgbd-sources/src/source.cpp @@ -285,7 +285,7 @@ Camera Camera::scaled(int width, int height) const { float scaleX = (float)width / (float)cam.width; float scaleY = (float)height / (float)cam.height; - CHECK( abs(scaleX - scaleY) < 0.000001f ); + CHECK( abs(scaleX - scaleY) < 0.00000001f ); Camera newcam = cam; newcam.width = width;