Skip to content
Snippets Groups Projects

CUDA optical flow smoothing

Merged Sebastian Hahta requested to merge feature/off-cuda into master
2 files
+ 34
35
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -27,55 +27,57 @@ public:
return available_[_channelIdx(channel)];
}
/* @brief Get reference to the channel data.
* @param Channel type
* @param Output parameter
* @param User of the method sets data. NOTE: Only works on unused
* channels or if reset() was called previously (TODO).
* @returns True, if output parameter contains valid data
/* @brief get reference to the channel contents
* @param channel type
* @returns const reference to channel data
*
* Methods automatically copy between host/gpu if the data is only available
* in the other. Results are cached.
* in the other. Results are cached. Result is valid only if hasChannel() is
* true.
*/
bool getChannel(const ftl::rgbd::channel_t& channel, cv::Mat& out, bool set=false)
const cv::Mat& getChannel(const ftl::rgbd::channel_t& channel)
{
auto idx = _channelIdx(channel);
bool retval = available_[idx] & mask_host;
if (!retval)
if (!(available_[idx] & mask_host))
{
if (available_[idx] & mask_gpu)
{
channels_gpu_[idx].download(channels_host_[idx]);
retval = true;
set = true;
available_[idx] |= mask_host;
}
}
if (set) { available_[idx] |= mask_host; }
return channels_host_[idx];
}
out = channels_host_[idx];
return retval;
cv::Mat& setChannel(const ftl::rgbd::channel_t& channel)
{
auto idx = _channelIdx(channel);
available_[idx] = mask_host;
return channels_host_[idx];
}
bool getChannel(const ftl::rgbd::channel_t& channel, cv::cuda::GpuMat& out, bool set=false)
const cv::cuda::GpuMat& getChannelGpu(const ftl::rgbd::channel_t& channel)
{
auto idx = _channelIdx(channel);
bool retval = available_[idx] & mask_gpu;
if (!retval)
if (!(available_[idx] & mask_gpu))
{
if (available_[idx] & mask_host)
{
channels_gpu_[idx].upload(channels_host_[idx]);
retval = true;
set = true;
available_[idx] |= mask_gpu;
}
}
if (set) { available_[idx] |= mask_host; }
out = channels_gpu_[idx];
return retval;
return channels_gpu_[idx];
}
cv::cuda::GpuMat& setChannelGpu(const ftl::rgbd::channel_t& channel)
{
auto idx = _channelIdx(channel);
available_[idx] = mask_gpu;
return channels_gpu_[idx];
}
private:
@@ -94,7 +96,8 @@ private:
case kChanConfidence: return 7;
case kChanFlow: return 8;
case kChanEnergy: return 9;
default: return 0; // should not happen (error)
// should not happen (error); returned index is kChanNone
default: return 0;
}
}
Loading