diff --git a/components/rgbd-sources/include/ftl/rgbd/source.hpp b/components/rgbd-sources/include/ftl/rgbd/source.hpp index 440f566edf40ed0ddb09bc301e3c571fd3823bc2..0b537aecda7e0afd88df6da96b2d7a3afda06286 100644 --- a/components/rgbd-sources/include/ftl/rgbd/source.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/source.hpp @@ -191,6 +191,10 @@ class Source : public ftl::Configurable { SHARED_MUTEX &mutex() { return mutex_; } + std::function<void(int64_t, const cv::Mat &, const cv::Mat &)> &callback() { return callback_; } + void setCallback(std::function<void(int64_t, const cv::Mat &, const cv::Mat &)> cb) { callback_ = cb; } + + private: detail::Source *impl_; cv::Mat rgb_; @@ -205,6 +209,7 @@ class Source : public ftl::Configurable { channel_t channel_; cudaStream_t stream_; int64_t timestamp_; + std::function<void(int64_t, const cv::Mat &, const cv::Mat &)> callback_; detail::Source *_createImplementation(); detail::Source *_createFileImpl(const ftl::URI &uri); diff --git a/components/rgbd-sources/src/net.cpp b/components/rgbd-sources/src/net.cpp index 25270084d577634c2e412f8e6f15c9fe847cf0b4..fb8ab483762a2f871199fae625c07ec445796b74 100644 --- a/components/rgbd-sources/src/net.cpp +++ b/components/rgbd-sources/src/net.cpp @@ -153,6 +153,13 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un timestamp_ = current_frame_*40; // FIXME: Don't hardcode 40ms current_frame_ = frame; + + if (host_->callback()) { + //ftl::pool.push([this](id) { + // UNIQUE_LOCK(host_->mutex(),lk); + host_->callback()(timestamp_, rgb_, depth_); + //}); + } } else if (frame < current_frame_) { LOG(WARNING) << "Chunk dropped"; if (chunk == 0) N_--;