diff --git a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp index baf7091bbe1c04be7b4328d91b9d902ff58a646e..3fbba3d586b829ea6e66c01570f0c0401b477605 100644 --- a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp +++ b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp @@ -109,6 +109,11 @@ ScreenCapture::~ScreenCapture() { #endif } +void ScreenCapture::swap() { + cur_ts_ = cap_ts_; + sframe_.swapTo(frame_); +} + bool ScreenCapture::retrieve() { if (!ready_) return false; cv::Mat img; @@ -118,19 +123,21 @@ bool ScreenCapture::retrieve() { img = cv::Mat(params_.height, params_.width, CV_8UC4, impl_state_->ximg->data); #endif - frame_.reset(); - frame_.setOrigin(&state_); + sframe_.reset(); + sframe_.setOrigin(&state_); if (!img.empty()) { - frame_.create<cv::cuda::GpuMat>(Channel::Colour).upload(img); + sframe_.create<cv::cuda::GpuMat>(Channel::Colour).upload(img); } + cap_ts_ = timestamp_; + return true; } bool ScreenCapture::compute(int n, int b) { if (!ready_) return false; - host_->notify(timestamp_, frame_); + host_->notify(cur_ts_, frame_); return true; } diff --git a/components/rgbd-sources/src/sources/screencapture/screencapture.hpp b/components/rgbd-sources/src/sources/screencapture/screencapture.hpp index e1511cb9abf39b47fe14d84a55697e0199761ab8..4c8ee78c4f4f05f2674fd05b6f64ed6d08c2d36c 100644 --- a/components/rgbd-sources/src/sources/screencapture/screencapture.hpp +++ b/components/rgbd-sources/src/sources/screencapture/screencapture.hpp @@ -23,12 +23,16 @@ class ScreenCapture : public ftl::rgbd::detail::Source { ~ScreenCapture(); bool capture(int64_t ts) { timestamp_ = ts; return true; }; + void swap() override; bool retrieve(); bool compute(int n=-1, int b=-1); bool isReady(); private: bool ready_; + int64_t cap_ts_; + int64_t cur_ts_; + ftl::rgbd::Frame sframe_; ImplState *impl_state_; };