diff --git a/applications/gui/src/camera.cpp b/applications/gui/src/camera.cpp index abb7fdb80100d85491dbf929909a8f1524365b2b..32d78a4a0ff8bbccfed60b13293b1277ab599792 100644 --- a/applications/gui/src/camera.cpp +++ b/applications/gui/src/camera.cpp @@ -376,7 +376,6 @@ const GLTexture &ftl::gui::Camera::captureFrame() { cv::Mat tmp; switch(channel_) { - case Channel::Normals: case Channel::Energy: if (depth_.rows == 0) { break; } visualizeEnergy(depth_, tmp, 10.0); @@ -400,6 +399,7 @@ const GLTexture &ftl::gui::Camera::captureFrame() { case Channel::Flow: case Channel::Confidence: + case Channel::Normals: case Channel::Right: if (depth_.rows == 0 || depth_.type() != CV_8UC3) { break; } texture_.update(depth_); diff --git a/components/renderers/cpp/include/ftl/cuda/normals.hpp b/components/renderers/cpp/include/ftl/cuda/normals.hpp index 0660dab19ca89e5769879210b4d34bfa403165aa..12d6b28ef872a4aaff4b2d264d426d865512b074 100644 --- a/components/renderers/cpp/include/ftl/cuda/normals.hpp +++ b/components/renderers/cpp/include/ftl/cuda/normals.hpp @@ -13,7 +13,7 @@ void normals(ftl::cuda::TextureObject<float4> &output, ftl::cuda::TextureObject<float4> &input, cudaStream_t stream); void normal_visualise(ftl::cuda::TextureObject<float4> &norm, - ftl::cuda::TextureObject<float> &output, + ftl::cuda::TextureObject<uchar4> &output, const float3 &light, cudaStream_t stream); diff --git a/components/renderers/cpp/src/normals.cu b/components/renderers/cpp/src/normals.cu index 05fe32b91d660c70a9f4b6097f2a18891b8878b4..47fc3bce291a3dc4c3d0e3aca454229dce3cba9c 100644 --- a/components/renderers/cpp/src/normals.cu +++ b/components/renderers/cpp/src/normals.cu @@ -89,14 +89,14 @@ void ftl::cuda::normals(ftl::cuda::TextureObject<float4> &output, //============================================================================== __global__ void vis_normals_kernel(ftl::cuda::TextureObject<float4> norm, - ftl::cuda::TextureObject<float> output, + ftl::cuda::TextureObject<uchar4> output, float3 light) { const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; if(x >= norm.width() || y >= norm.height()) return; - output(x,y) = 0.0f; + output(x,y) = make_uchar4(0,0,0,0); float3 ray = light; //pose.getFloat3x3() * camera.screenToCam(x,y,1.0f); ray = ray / length(ray); float3 n = make_float3(norm.tex2D((int)x,(int)y)); @@ -104,8 +104,8 @@ __global__ void vis_normals_kernel(ftl::cuda::TextureObject<float4> norm, if (l == 0) return; n /= l; - const float d = dot(ray, n); - output(x,y) = (1.0f + d)*3.5f; // FIXME: Do not hard code these value scalings + const float d = max(dot(ray, n), 0.0f); + output(x,y) = make_uchar4(200*d,200*d,200*d,255); //if (d > 0.2f) { // output(x,y) = d * 7.0f; @@ -113,7 +113,7 @@ __global__ void vis_normals_kernel(ftl::cuda::TextureObject<float4> norm, } void ftl::cuda::normal_visualise(ftl::cuda::TextureObject<float4> &norm, - ftl::cuda::TextureObject<float> &output, + ftl::cuda::TextureObject<uchar4> &output, const float3 &light, cudaStream_t stream) { diff --git a/components/renderers/cpp/src/splat_render.cpp b/components/renderers/cpp/src/splat_render.cpp index 25b2d86329e395e93129d1a488c32eb32535a5d2..b43b96927cfbfe7d0238bde6d267b5fa7c530464 100644 --- a/components/renderers/cpp/src/splat_render.cpp +++ b/components/renderers/cpp/src/splat_render.cpp @@ -322,11 +322,11 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda renderChannel(params, out, Channel::Normals, stream); // Convert normal to single float value - temp_.create<GpuMat>(Channel::Contribution, Format<float>(camera.width, camera.height)); - ftl::cuda::normal_visualise(out.getTexture<float4>(Channel::Normals), temp_.createTexture<float>(Channel::Contribution), make_float3(0.0f, 0.0f, 1.0f), stream); + temp_.create<GpuMat>(Channel::Colour, Format<uchar4>(camera.width, camera.height)); + ftl::cuda::normal_visualise(out.getTexture<float4>(Channel::Normals), temp_.createTexture<uchar4>(Channel::Colour), make_float3(0.0f, 0.0f, 1.0f), stream); // Put in output as single float - cv::cuda::swap(temp_.get<GpuMat>(Channel::Contribution), out.create<GpuMat>(Channel::Normals)); + cv::cuda::swap(temp_.get<GpuMat>(Channel::Colour), out.create<GpuMat>(Channel::Normals)); out.resetTexture(Channel::Normals); } else if (chan == Channel::Contribution) diff --git a/components/rgbd-sources/include/ftl/rgbd/channels.hpp b/components/rgbd-sources/include/ftl/rgbd/channels.hpp index d1d8dcdbf2f66841f5e12da01d04a4438e145d23..e89a42ce3c808e254e8ae6085b4517a1f74bd79d 100644 --- a/components/rgbd-sources/include/ftl/rgbd/channels.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/channels.hpp @@ -103,7 +103,7 @@ static const Channels kAllChannels(0xFFFFFFFFu); inline bool isFloatChannel(ftl::rgbd::Channel chan) { switch (chan) { case Channel::Depth : - case Channel::Normals : + //case Channel::Normals : case Channel::Energy : return true; default : return false; }