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

Add show bad colour option

parent 4c894248
No related branches found
No related tags found
No related merge requests found
...@@ -441,9 +441,11 @@ __global__ void dibr_normalise_kernel( ...@@ -441,9 +441,11 @@ __global__ void dibr_normalise_kernel(
const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
if (x < in.width() && y < in.height()) { if (x < in.width() && y < in.height()) {
const float contrib = contribs.tex2D((int)x,(int)y);
const A a = in.tex2D((int)x,(int)y); const A a = in.tex2D((int)x,(int)y);
//const float4 normal = normals.tex2D((int)x,(int)y); //const float4 normal = normals.tex2D((int)x,(int)y);
const float contrib = contribs.tex2D((int)x,(int)y);
//out(x,y) = (contrib == 0.0f) ? make<B>(a) : make<B>(a / contrib);
if (contrib > 0.0f) { if (contrib > 0.0f) {
out(x,y) = make<B>(a / contrib); out(x,y) = make<B>(a / contrib);
...@@ -464,3 +466,39 @@ void ftl::cuda::dibr_normalise(TextureObject<A> &in, TextureObject<B> &out, Text ...@@ -464,3 +466,39 @@ void ftl::cuda::dibr_normalise(TextureObject<A> &in, TextureObject<B> &out, Text
template void ftl::cuda::dibr_normalise<float4,uchar4>(TextureObject<float4> &in, TextureObject<uchar4> &out, TextureObject<float> &contribs, cudaStream_t stream); template void ftl::cuda::dibr_normalise<float4,uchar4>(TextureObject<float4> &in, TextureObject<uchar4> &out, TextureObject<float> &contribs, cudaStream_t stream);
template void ftl::cuda::dibr_normalise<float,float>(TextureObject<float> &in, TextureObject<float> &out, TextureObject<float> &contribs, cudaStream_t stream); template void ftl::cuda::dibr_normalise<float,float>(TextureObject<float> &in, TextureObject<float> &out, TextureObject<float> &contribs, cudaStream_t stream);
template void ftl::cuda::dibr_normalise<float4,float4>(TextureObject<float4> &in, TextureObject<float4> &out, TextureObject<float> &contribs, cudaStream_t stream); template void ftl::cuda::dibr_normalise<float4,float4>(TextureObject<float4> &in, TextureObject<float4> &out, TextureObject<float> &contribs, cudaStream_t stream);
// ===== Show bad colour normalise =============================================
__global__ void show_missing_colour_kernel(
TextureObject<float> depth,
TextureObject<uchar4> out,
TextureObject<float> contribs,
uchar4 bad_colour,
ftl::rgbd::Camera cam) {
const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
if (x < out.width() && y < out.height()) {
const float contrib = contribs.tex2D((int)x,(int)y);
const float d = depth.tex2D(x,y);
if (contrib < 0.0000001f && d > cam.minDepth && d < cam.maxDepth) {
out(x,y) = bad_colour;
}
}
}
void ftl::cuda::show_missing_colour(
TextureObject<float> &depth,
TextureObject<uchar4> &out,
TextureObject<float> &contribs,
uchar4 bad_colour,
const ftl::rgbd::Camera &cam,
cudaStream_t stream) {
const dim3 gridSize((out.width() + T_PER_BLOCK - 1)/T_PER_BLOCK, (out.height() + T_PER_BLOCK - 1)/T_PER_BLOCK);
const dim3 blockSize(T_PER_BLOCK, T_PER_BLOCK);
show_missing_colour_kernel<<<gridSize, blockSize, 0, stream>>>(depth, out, contribs, bad_colour, cam);
cudaSafeCall( cudaGetLastError() );
}
...@@ -97,6 +97,14 @@ namespace cuda { ...@@ -97,6 +97,14 @@ namespace cuda {
ftl::cuda::TextureObject<float> &contribs, ftl::cuda::TextureObject<float> &contribs,
cudaStream_t stream); cudaStream_t stream);
void show_missing_colour(
ftl::cuda::TextureObject<float> &depth,
ftl::cuda::TextureObject<uchar4> &out,
ftl::cuda::TextureObject<float> &contribs,
uchar4 bad_colour,
const ftl::rgbd::Camera &cam,
cudaStream_t stream);
void show_mask( void show_mask(
ftl::cuda::TextureObject<uchar4> &colour, ftl::cuda::TextureObject<uchar4> &colour,
ftl::cuda::TextureObject<int> &mask, ftl::cuda::TextureObject<int> &mask,
......
...@@ -603,6 +603,17 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) { ...@@ -603,6 +603,17 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) {
// Reprojection of colours onto surface // Reprojection of colours onto surface
_renderChannel(out, Channel::Colour, Channel::Colour, stream_); _renderChannel(out, Channel::Colour, Channel::Colour, stream_);
if (value("show_bad_colour", false)) {
ftl::cuda::show_missing_colour(
out.getTexture<float>(Channel::Depth),
out.getTexture<uchar4>(Channel::Colour),
temp_.getTexture<float>(Channel::Contribution),
make_uchar4(255,0,0,0),
camera,
stream_
);
}
if (chan == Channel::Depth) if (chan == Channel::Depth)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment