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

Working smoothing channel

parent 481406f4
No related branches found
No related tags found
1 merge request!158Implements #228 adaptive MLS and smoothing channel
This commit is part of merge request !158. Comments created here will be created in the context of that merge request.
...@@ -43,7 +43,7 @@ class SmoothChannel : public ftl::operators::Operator { ...@@ -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; bool apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd::Source *src, cudaStream_t stream) override;
private: private:
ftl::rgbd::Frame temp_[2]; ftl::rgbd::Frame temp_[6];
}; };
/** /**
......
...@@ -71,8 +71,9 @@ SmoothChannel::~SmoothChannel() { ...@@ -71,8 +71,9 @@ SmoothChannel::~SmoothChannel() {
} }
bool SmoothChannel::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd::Source *s, cudaStream_t stream) { 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); float threshold = config()->value("threshold", 30.0f);
int iters = max(0, min(6, config()->value("levels", 4)));
int width = s->parameters().width; int width = s->parameters().width;
int height = s->parameters().height; int height = s->parameters().height;
...@@ -91,24 +92,26 @@ bool SmoothChannel::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd ...@@ -91,24 +92,26 @@ bool SmoothChannel::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd
stream stream
); );
for (int i=0; i<iters; ++i) {
width /= 2; width /= 2;
height /= 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 // 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::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_[0].create<GpuMat>(Channel::Depth), cv::Size(width, height), 0.0, 0.0, cv::INTER_NEAREST); 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( ftl::cuda::smooth_channel(
temp_[0].createTexture<uchar4>(Channel::Colour), temp_[i].createTexture<uchar4>(Channel::Colour),
temp_[0].createTexture<float>(Channel::Depth), temp_[i].createTexture<float>(Channel::Depth),
out.getTexture<float>(Channel::Smoothing), out.getTexture<float>(Channel::Smoothing),
scaledCam, scaledCam,
threshold, threshold,
radius, radius,
stream stream
); );
}
return true; return true;
} }
......
...@@ -285,7 +285,7 @@ Camera Camera::scaled(int width, int height) const { ...@@ -285,7 +285,7 @@ Camera Camera::scaled(int width, int height) const {
float scaleX = (float)width / (float)cam.width; float scaleX = (float)width / (float)cam.width;
float scaleY = (float)height / (float)cam.height; float scaleY = (float)height / (float)cam.height;
CHECK( abs(scaleX - scaleY) < 0.000001f ); CHECK( abs(scaleX - scaleY) < 0.00000001f );
Camera newcam = cam; Camera newcam = cam;
newcam.width = width; newcam.width = width;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment