Skip to content
Snippets Groups Projects
Commit f35c5048 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

do not use width&height from params

parent 51570f47
No related branches found
No related tags found
1 merge request!196High resolution colour
Pipeline #16766 passed
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
using ftl::cuda::Mask; using ftl::cuda::Mask;
template <int RADIUS> template <int RADIUS>
__global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl::cuda::TextureObject<float> depth, ftl::rgbd::Camera params) { __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl::cuda::TextureObject<float> depth,
const cv::Size size, const double minDepth, const double maxDepth) {
const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
if (x < params.width && y < params.height) { if (x < size.width && y < size.height) {
Mask mask(0); Mask mask(0);
const float d = depth.tex2D((int)x, (int)y); const float d = depth.tex2D((int)x, (int)y);
...@@ -17,7 +18,7 @@ __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl ...@@ -17,7 +18,7 @@ __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl
// Calculate depth between 0.0 and 1.0 // Calculate depth between 0.0 and 1.0
//float p = (d - params.minDepth) / (params.maxDepth - params.minDepth); //float p = (d - params.minDepth) / (params.maxDepth - params.minDepth);
if (d >= params.minDepth && d <= params.maxDepth) { if (d >= minDepth && d <= maxDepth) {
/* Orts-Escolano S. et al. 2016. Holoportation: Virtual 3D teleportation in real-time. */ /* Orts-Escolano S. et al. 2016. Holoportation: Virtual 3D teleportation in real-time. */
// Is there a discontinuity nearby? // Is there a discontinuity nearby?
for (int u=-RADIUS; u<=RADIUS; ++u) { for (int u=-RADIUS; u<=RADIUS; ++u) {
...@@ -32,16 +33,19 @@ __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl ...@@ -32,16 +33,19 @@ __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl
} }
} }
void ftl::cuda::discontinuity(ftl::cuda::TextureObject<int> &mask_out, ftl::cuda::TextureObject<float> &depth, const ftl::rgbd::Camera &params, uint discon, cudaStream_t stream) { void ftl::cuda::discontinuity(ftl::cuda::TextureObject<int> &mask_out, ftl::cuda::TextureObject<float> &depth,
const dim3 gridSize((params.width + T_PER_BLOCK - 1)/T_PER_BLOCK, (params.height + T_PER_BLOCK - 1)/T_PER_BLOCK); const cv::Size size, const double minDepth, const double maxDepth,
uint discon, cudaStream_t stream) {
const dim3 gridSize((size.width + T_PER_BLOCK - 1)/T_PER_BLOCK, (size.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);
switch (discon) { switch (discon) {
case 5 : discontinuity_kernel<5><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, params); break; case 5 : discontinuity_kernel<5><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, size, minDepth, maxDepth); break;
case 4 : discontinuity_kernel<4><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, params); break; case 4 : discontinuity_kernel<4><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, size, minDepth, maxDepth); break;
case 3 : discontinuity_kernel<3><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, params); break; case 3 : discontinuity_kernel<3><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, size, minDepth, maxDepth); break;
case 2 : discontinuity_kernel<2><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, params); break; case 2 : discontinuity_kernel<2><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, size, minDepth, maxDepth); break;
case 1 : discontinuity_kernel<1><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, params); break; case 1 : discontinuity_kernel<1><<<gridSize, blockSize, 0, stream>>>(mask_out, depth, size, minDepth, maxDepth); break;
default: break; default: break;
} }
cudaSafeCall( cudaGetLastError() ); cudaSafeCall( cudaGetLastError() );
......
...@@ -29,7 +29,9 @@ static const uint kILWFlag_ColourConfidenceOnly = 0x0008; ...@@ -29,7 +29,9 @@ static const uint kILWFlag_ColourConfidenceOnly = 0x0008;
void discontinuity( void discontinuity(
ftl::cuda::TextureObject<int> &mask_out, ftl::cuda::TextureObject<int> &mask_out,
ftl::cuda::TextureObject<float> &depth, ftl::cuda::TextureObject<float> &depth,
const ftl::rgbd::Camera &params, const cv::Size size,
const double minDepth,
const double maxDepth,
uint discon, cudaStream_t stream uint discon, cudaStream_t stream
); );
......
...@@ -22,7 +22,9 @@ bool DiscontinuityMask::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl:: ...@@ -22,7 +22,9 @@ bool DiscontinuityMask::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::
out.createTexture<int>(Channel::Mask, ftl::rgbd::Format<int>(in.get<cv::cuda::GpuMat>(Channel::Depth).size())), out.createTexture<int>(Channel::Mask, ftl::rgbd::Format<int>(in.get<cv::cuda::GpuMat>(Channel::Depth).size())),
in.createTexture<uchar4>(Channel::Support1), in.createTexture<uchar4>(Channel::Support1),
in.createTexture<float>(Channel::Depth), in.createTexture<float>(Channel::Depth),
s->parameters(), radius, threshold, stream in.get<cv::cuda::GpuMat>(Channel::Depth).size(),
s->parameters().minDepth, s->parameters().maxDepth,
radius, threshold, stream
); );
return true; return true;
......
...@@ -4,16 +4,21 @@ ...@@ -4,16 +4,21 @@
using ftl::cuda::Mask; using ftl::cuda::Mask;
__global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl::cuda::TextureObject<uchar4> support, ftl::cuda::TextureObject<float> depth, ftl::rgbd::Camera params, float threshold, int radius) { __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out,
ftl::cuda::TextureObject<uchar4> support,
ftl::cuda::TextureObject<float> depth,
const cv::Size size, const double minDepth, const double maxDepth,
float threshold, int radius) {
const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
if (x < params.width && y < params.height) { if (x < size.width && y < size.height) {
Mask mask(0); Mask mask(0);
const float d = depth.tex2D((int)x, (int)y); const float d = depth.tex2D((int)x, (int)y);
if (d >= params.minDepth && d <= params.maxDepth) { if (d >= minDepth && d <= maxDepth) {
/* Orts-Escolano S. et al. 2016. Holoportation: Virtual 3D teleportation in real-time. */ /* Orts-Escolano S. et al. 2016. Holoportation: Virtual 3D teleportation in real-time. */
// If colour cross support region terminates within the requested // If colour cross support region terminates within the requested
...@@ -43,11 +48,15 @@ __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl ...@@ -43,11 +48,15 @@ __global__ void discontinuity_kernel(ftl::cuda::TextureObject<int> mask_out, ftl
} }
} }
void ftl::cuda::discontinuity(ftl::cuda::TextureObject<int> &mask_out, ftl::cuda::TextureObject<uchar4> &support, ftl::cuda::TextureObject<float> &depth, const ftl::rgbd::Camera &params, int discon, float thresh, cudaStream_t stream) { void ftl::cuda::discontinuity( ftl::cuda::TextureObject<int> &mask_out, ftl::cuda::TextureObject<uchar4> &support,
const dim3 gridSize((params.width + T_PER_BLOCK - 1)/T_PER_BLOCK, (params.height + T_PER_BLOCK - 1)/T_PER_BLOCK); ftl::cuda::TextureObject<float> &depth,
const cv::Size size, const double minDepth, const double maxDepth,
int discon, float thresh, cudaStream_t stream) {
const dim3 gridSize((size.width + T_PER_BLOCK - 1)/T_PER_BLOCK, (size.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);
discontinuity_kernel<<<gridSize, blockSize, 0, stream>>>(mask_out, support, depth, params, thresh, discon); discontinuity_kernel<<<gridSize, blockSize, 0, stream>>>(mask_out, support, depth, size, minDepth, maxDepth, thresh, discon);
cudaSafeCall( cudaGetLastError() ); cudaSafeCall( cudaGetLastError() );
#ifdef _DEBUG #ifdef _DEBUG
...@@ -55,8 +64,6 @@ void ftl::cuda::discontinuity(ftl::cuda::TextureObject<int> &mask_out, ftl::cuda ...@@ -55,8 +64,6 @@ void ftl::cuda::discontinuity(ftl::cuda::TextureObject<int> &mask_out, ftl::cuda
#endif #endif
} }
__global__ void cull_discontinuity_kernel(ftl::cuda::TextureObject<int> mask, ftl::cuda::TextureObject<float> depth) { __global__ void cull_discontinuity_kernel(ftl::cuda::TextureObject<int> mask, ftl::cuda::TextureObject<float> depth) {
const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
......
...@@ -44,7 +44,9 @@ void discontinuity( ...@@ -44,7 +44,9 @@ void discontinuity(
ftl::cuda::TextureObject<int> &mask, ftl::cuda::TextureObject<int> &mask,
ftl::cuda::TextureObject<uchar4> &support, ftl::cuda::TextureObject<uchar4> &support,
ftl::cuda::TextureObject<float> &depth, ftl::cuda::TextureObject<float> &depth,
const ftl::rgbd::Camera &params, const cv::Size size,
const double minDepth,
const double maxDepth,
int radius, float threshold, int radius, float threshold,
cudaStream_t stream); cudaStream_t stream);
......
...@@ -130,12 +130,12 @@ void StereoVideoSource::init(const string &file) { ...@@ -130,12 +130,12 @@ void StereoVideoSource::init(const string &file) {
pipeline_input_->append<ftl::operators::NVOpticalFlow>("optflow"); pipeline_input_->append<ftl::operators::NVOpticalFlow>("optflow");
#endif #endif
depth_size_ = cv::Size( host_->value("width", color_size_.width),
host_->value("height", color_size_.height));
pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity"); pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity");
pipeline_depth_->append<ftl::operators::FixstarsSGM>("algorithm");
depth_size_ = cv::Size( pipeline_depth_->value("width", color_size_.width),
pipeline_depth_->value("height", color_size_.height));
pipeline_depth_->append<ftl::operators::FixstarsSGM>("algorithm");
#ifdef HAVE_OPTFLOW #ifdef HAVE_OPTFLOW
pipeline_depth_->append<ftl::operators::OpticalFlowTemporalSmoothing>("optflow_filter"); pipeline_depth_->append<ftl::operators::OpticalFlowTemporalSmoothing>("optflow_filter");
#endif #endif
...@@ -207,24 +207,27 @@ bool StereoVideoSource::compute(int n, int b) { ...@@ -207,24 +207,27 @@ bool StereoVideoSource::compute(int n, int b) {
} }
if (chan == Channel::Depth) { if (chan == Channel::Depth) {
// stereo algorithms assume input same size as output, resize if // stereo algorithms assume input same size as output
// necessary
bool resize = (depth_size_ != color_size_); bool resize = (depth_size_ != color_size_);
if (resize) {
cv::cuda::GpuMat& left = frame.get<cv::cuda::GpuMat>(Channel::Left); cv::cuda::GpuMat& left = frame.get<cv::cuda::GpuMat>(Channel::Left);
cv::cuda::GpuMat& right = frame.get<cv::cuda::GpuMat>(Channel::Right); cv::cuda::GpuMat& right = frame.get<cv::cuda::GpuMat>(Channel::Right);
if (left.empty() || right.empty()) {
return false;
}
if (resize) {
std::swap(fullres_left_, left); std::swap(fullres_left_, left);
std::swap(fullres_right_, right); std::swap(fullres_right_, right);
cv::cuda::resize(fullres_left_, left, depth_size_, 0.0, 0.0, cv::INTER_CUBIC, stream_); cv::cuda::resize(fullres_left_, left, depth_size_, 0, 0, cv::INTER_CUBIC, stream_);
cv::cuda::resize(fullres_right_, right, depth_size_, 0.0, 0.0, cv::INTER_CUBIC, stream_); cv::cuda::resize(fullres_right_, right, depth_size_, 0, 0, cv::INTER_CUBIC, stream_);
} }
pipeline_depth_->apply(frame, frame, host_, cv::cuda::StreamAccessor::getStream(stream_)); pipeline_depth_->apply(frame, frame, host_, cv::cuda::StreamAccessor::getStream(stream_));
stream_.waitForCompletion(); stream_.waitForCompletion();
if (resize) { if (resize) {
cv::cuda::GpuMat &left = frame.get<cv::cuda::GpuMat>(Channel::Left);
cv::cuda::GpuMat &right = frame.get<cv::cuda::GpuMat>(Channel::Right);
std::swap(fullres_left_, left); std::swap(fullres_left_, left);
std::swap(fullres_right_, right); std::swap(fullres_right_, right);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment