From 2c14e0faf9c089df5ffb12c41932524d79c1f748 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 7 Aug 2019 20:12:32 +0300
Subject: [PATCH] WIP Fix for snapshot and recon

---
 components/rgbd-sources/src/snapshot_source.cpp | 11 ++++++++++-
 components/rgbd-sources/src/snapshot_source.hpp |  6 ++++--
 components/rgbd-sources/src/source.cpp          |  8 ++++----
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/components/rgbd-sources/src/snapshot_source.cpp b/components/rgbd-sources/src/snapshot_source.cpp
index 030e56dd4..aa5268549 100644
--- a/components/rgbd-sources/src/snapshot_source.cpp
+++ b/components/rgbd-sources/src/snapshot_source.cpp
@@ -15,7 +15,10 @@ using std::vector;
 
 SnapshotSource::SnapshotSource(ftl::rgbd::Source *host, SnapshotReader &reader, const string &id) : detail::Source(host) {
     Eigen::Matrix4d pose;
-    reader.getCameraRGBD(id, rgb_, depth_, pose, params_);
+    reader.getCameraRGBD(id, snap_rgb_, snap_depth_, pose, params_);
+
+	rgb_ = snap_rgb_;
+	depth_ = snap_depth_;
 
 	if (rgb_.empty()) LOG(ERROR) << "Did not load snapshot rgb - " << id;
 	if (depth_.empty()) LOG(ERROR) << "Did not load snapshot depth - " << id;
@@ -50,3 +53,9 @@ SnapshotSource::SnapshotSource(ftl::rgbd::Source *host, SnapshotReader &reader,
 
     host->setPose(pose);
 }
+
+bool SnapshotSource::compute(int n, int b) {
+	snap_rgb_.copyTo(rgb_);
+	snap_depth_.copyTo(depth_);
+	return true;
+}
diff --git a/components/rgbd-sources/src/snapshot_source.hpp b/components/rgbd-sources/src/snapshot_source.hpp
index abc8fd76b..eb4e58594 100644
--- a/components/rgbd-sources/src/snapshot_source.hpp
+++ b/components/rgbd-sources/src/snapshot_source.hpp
@@ -17,11 +17,13 @@ class SnapshotSource : public detail::Source {
 	SnapshotSource(ftl::rgbd::Source *, ftl::rgbd::SnapshotReader &reader, const std::string &id);
 	~SnapshotSource() {};
 
-	bool compute(int n, int b) override { return true; };
+	bool compute(int n, int b);
 	bool isReady() { return true; }
 
 	//void reset();
-
+	private:
+	cv::Mat snap_rgb_;
+	cv::Mat snap_depth_;
 };
 
 }
diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp
index 4a3b7093b..913fe4acb 100644
--- a/components/rgbd-sources/src/source.cpp
+++ b/components/rgbd-sources/src/source.cpp
@@ -165,18 +165,18 @@ ftl::rgbd::detail::Source *Source::_createDeviceImpl(const ftl::URI &uri) {
 
 void Source::getFrames(cv::Mat &rgb, cv::Mat &depth) {
 	SHARED_LOCK(mutex_,lk);
-	//rgb_.copyTo(rgb);
-	//depth_.copyTo(depth);
+	rgb_.copyTo(rgb);
+	depth_.copyTo(depth);
 	//rgb = rgb_;
 	//depth = depth_;
 
-	cv::Mat tmp;
+	/*cv::Mat tmp;
 	tmp = rgb;
 	rgb = rgb_;
 	rgb_ = tmp;
 	tmp = depth;
 	depth = depth_;
-	depth_ = tmp;
+	depth_ = tmp;*/
 }
 
 Eigen::Vector4d Source::point(uint ux, uint uy) {
-- 
GitLab