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

Switch to streams for snapshot source

parent b56a9bcd
No related branches found
No related tags found
No related merge requests found
Pipeline #17204 passed
...@@ -53,6 +53,8 @@ SnapshotSource::SnapshotSource(ftl::rgbd::Source *host, Snapshot &snapshot, cons ...@@ -53,6 +53,8 @@ SnapshotSource::SnapshotSource(ftl::rgbd::Source *host, Snapshot &snapshot, cons
host->setPose(pose); host->setPose(pose);
mspf_ = 1000 / host_->value("fps", 20); mspf_ = 1000 / host_->value("fps", 20);
cudaStreamCreate(&stream_);
} }
bool SnapshotSource::compute(int n, int b) { bool SnapshotSource::compute(int n, int b) {
...@@ -61,11 +63,14 @@ bool SnapshotSource::compute(int n, int b) { ...@@ -61,11 +63,14 @@ bool SnapshotSource::compute(int n, int b) {
//snap_rgb_.copyTo(rgb_); //snap_rgb_.copyTo(rgb_);
//snap_depth_.copyTo(depth_); //snap_depth_.copyTo(depth_);
rgb_.upload(snap_rgb_); cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream_);
depth_.upload(snap_depth_); rgb_.upload(snap_rgb_, cvstream);
depth_.upload(snap_depth_, cvstream);
auto cb = host_->callback(); cudaStreamSynchronize(stream_);
if (cb) cb(timestamp_, rgb_, depth_);
//auto cb = host_->callback();
//if (cb) cb(timestamp_, rgb_, depth_);
host_->notify(timestamp_, rgb_, depth_);
frame_idx_ = (frame_idx_ + 1) % snapshot_.getFramesCount(); frame_idx_ = (frame_idx_ + 1) % snapshot_.getFramesCount();
......
...@@ -32,6 +32,7 @@ class SnapshotSource : public detail::Source { ...@@ -32,6 +32,7 @@ class SnapshotSource : public detail::Source {
cv::Mat snap_rgb_; cv::Mat snap_rgb_;
cv::Mat snap_depth_; cv::Mat snap_depth_;
int mspf_; int mspf_;
cudaStream_t stream_;
}; };
} }
......
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