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

Improve screen capture correctness and timing

parent f7e71730
No related branches found
No related tags found
1 merge request!240Reduce screen capture latency
...@@ -109,6 +109,11 @@ ScreenCapture::~ScreenCapture() { ...@@ -109,6 +109,11 @@ ScreenCapture::~ScreenCapture() {
#endif #endif
} }
void ScreenCapture::swap() {
cur_ts_ = cap_ts_;
sframe_.swapTo(frame_);
}
bool ScreenCapture::retrieve() { bool ScreenCapture::retrieve() {
if (!ready_) return false; if (!ready_) return false;
cv::Mat img; cv::Mat img;
...@@ -118,19 +123,21 @@ bool ScreenCapture::retrieve() { ...@@ -118,19 +123,21 @@ bool ScreenCapture::retrieve() {
img = cv::Mat(params_.height, params_.width, CV_8UC4, impl_state_->ximg->data); img = cv::Mat(params_.height, params_.width, CV_8UC4, impl_state_->ximg->data);
#endif #endif
frame_.reset(); sframe_.reset();
frame_.setOrigin(&state_); sframe_.setOrigin(&state_);
if (!img.empty()) { 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; return true;
} }
bool ScreenCapture::compute(int n, int b) { bool ScreenCapture::compute(int n, int b) {
if (!ready_) return false; if (!ready_) return false;
host_->notify(timestamp_, frame_); host_->notify(cur_ts_, frame_);
return true; return true;
} }
......
...@@ -23,12 +23,16 @@ class ScreenCapture : public ftl::rgbd::detail::Source { ...@@ -23,12 +23,16 @@ class ScreenCapture : public ftl::rgbd::detail::Source {
~ScreenCapture(); ~ScreenCapture();
bool capture(int64_t ts) { timestamp_ = ts; return true; }; bool capture(int64_t ts) { timestamp_ = ts; return true; };
void swap() override;
bool retrieve(); bool retrieve();
bool compute(int n=-1, int b=-1); bool compute(int n=-1, int b=-1);
bool isReady(); bool isReady();
private: private:
bool ready_; bool ready_;
int64_t cap_ts_;
int64_t cur_ts_;
ftl::rgbd::Frame sframe_;
ImplState *impl_state_; ImplState *impl_state_;
}; };
......
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