From e8e76717c0ddc0647dc584518a8d28b8dfe9d900 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 18 Sep 2019 18:36:17 +0300
Subject: [PATCH] Fix incorrect camera transformations

---
 components/rgbd-sources/include/ftl/rgbd/camera.hpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/components/rgbd-sources/include/ftl/rgbd/camera.hpp b/components/rgbd-sources/include/ftl/rgbd/camera.hpp
index 5e410ab5e..e245be1ea 100644
--- a/components/rgbd-sources/include/ftl/rgbd/camera.hpp
+++ b/components/rgbd-sources/include/ftl/rgbd/camera.hpp
@@ -44,8 +44,8 @@ struct __align__(16) Camera {
 template <> __device__
 inline float2 ftl::rgbd::Camera::camToScreen<float2>(const float3 &pos) const {
 	return make_float2(
-			pos.x*fx/pos.z + cx,			
-			pos.y*fy/pos.z + cy);
+			pos.x*fx/pos.z - cx,			
+			pos.y*fy/pos.z - cy);
 }
 
 template <> __device__
@@ -62,8 +62,8 @@ inline uint2 ftl::rgbd::Camera::camToScreen<uint2>(const float3 &pos) const {
 
 __device__
 inline float3 ftl::rgbd::Camera::screenToCam(uint ux, uint uy, float depth) const {
-	const float x = ((float)ux-cx) / fx;
-	const float y = ((float)uy-cy) / fy;
+	const float x = ((float)ux+cx) / fx;
+	const float y = ((float)uy+cy) / fy;
 	return make_float3(depth*x, depth*y, depth);
 }
 
-- 
GitLab