From c50cfc32e2bbdb5149ac6dbb548a69e0d8e39b91 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 13 Jun 2019 12:35:20 +0300
Subject: [PATCH] Output depth in recon raycast mode

---
 applications/reconstruct/include/ftl/ray_cast_sdf.hpp | 2 ++
 applications/reconstruct/src/virtual_source.cpp       | 9 +++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/applications/reconstruct/include/ftl/ray_cast_sdf.hpp b/applications/reconstruct/include/ftl/ray_cast_sdf.hpp
index 658e8ceeb..d796b1cfc 100644
--- a/applications/reconstruct/include/ftl/ray_cast_sdf.hpp
+++ b/applications/reconstruct/include/ftl/ray_cast_sdf.hpp
@@ -18,6 +18,8 @@ public:
 		hash_render_ = value("hash_renderer", false);
 	}
 
+	bool isIntegerDepth() const { return hash_render_; }
+
 	~CUDARayCastSDF(void) {
 		destroy();
 	}
diff --git a/applications/reconstruct/src/virtual_source.cpp b/applications/reconstruct/src/virtual_source.cpp
index 072f71cb5..157b71a3d 100644
--- a/applications/reconstruct/src/virtual_source.cpp
+++ b/applications/reconstruct/src/virtual_source.cpp
@@ -26,6 +26,7 @@ VirtualSource::VirtualSource(ftl::rgbd::Source *host)
 
 	rgb_ = cv::Mat(cv::Size(params_.width,params_.height), CV_8UC3);
 	idepth_ = cv::Mat(cv::Size(params_.width,params_.height), CV_32SC1);
+	depth_ = cv::Mat(cv::Size(params_.width,params_.height), CV_32FC1);
 }
 
 VirtualSource::~VirtualSource() {
@@ -52,8 +53,12 @@ bool VirtualSource::grab() {
 		rays_->render(scene_->getHashData(), scene_->getHashParams(), params, host_->getPose());
 
 		//unique_lock<mutex> lk(mutex_);
-		rays_->getRayCastData().download((int*)idepth_.data, (uchar3*)rgb_.data, rays_->getRayCastParams());
-		idepth_.convertTo(depth_, CV_32FC1, 1.0f / 100.0f);
+		if (rays_->isIntegerDepth()) {
+			rays_->getRayCastData().download((int*)idepth_.data, (uchar3*)rgb_.data, rays_->getRayCastParams());
+			idepth_.convertTo(depth_, CV_32FC1, 1.0f / 100.0f);
+		} else {
+			rays_->getRayCastData().download((int*)depth_.data, (uchar3*)rgb_.data, rays_->getRayCastParams());
+		}
 	}
 	return true;
 }
-- 
GitLab