From 817ea878875750130f01bdd2e219785519d27e1f Mon Sep 17 00:00:00 2001
From: Sebastian Hahta <joseha@utu.fi>
Date: Tue, 28 Jul 2020 19:06:25 +0300
Subject: [PATCH] rectification.cpp: flip l/r

---
 .../rgbd-sources/src/sources/stereovideo/rectification.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/components/rgbd-sources/src/sources/stereovideo/rectification.cpp b/components/rgbd-sources/src/sources/stereovideo/rectification.cpp
index a9395664c..a590b76ed 100644
--- a/components/rgbd-sources/src/sources/stereovideo/rectification.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/rectification.cpp
@@ -66,6 +66,7 @@ void StereoRectification::calculateParameters() {
 		valid &= calib_right_.intrinsic.resolution != cv::Size{0, 0};
 		valid &= validate::cameraMatrix(calib_left_.intrinsic.matrix());
 		valid &= validate::cameraMatrix(calib_right_.intrinsic.matrix());
+		valid &= (calib_left_.extrinsic.tvec != calib_right_.extrinsic.tvec);
 		if (!valid) { return; }
 	}
 
@@ -73,13 +74,9 @@ void StereoRectification::calculateParameters() {
 
 	// create temporary buffers for rectification
 	if (tmp_l_.size() != image_resolution_) {
-		//using cv::cuda::HostMem;
-		//tmp_l_ = HostMem(image_resolution_, CV_8UC4, HostMem::AllocType::PAGE_LOCKED);
 		tmp_l_ = cv::Mat(image_resolution_, CV_8UC4);
 	}
 	if (tmp_l_.size() != image_resolution_) {
-		//using cv::cuda::HostMem;
-		//tmp_r_ = HostMem(image_resolution_, CV_8UC4, HostMem::AllocType::PAGE_LOCKED);
 		tmp_r_ = cv::Mat(image_resolution_, CV_8UC4);
 	}
 
@@ -91,7 +88,7 @@ void StereoRectification::calculateParameters() {
 	// calculate rotation and translation from left to right using calibration
 	cv::Mat T_l = calib_left_.extrinsic.matrix();
 	cv::Mat T_r = calib_right_.extrinsic.matrix();
-	cv::Mat T = T_l * transform::inverse(T_r);
+	cv::Mat T = T_r * transform::inverse(T_l);
 	cv::Mat R, t;
 
 	transform::getRotationAndTranslation(T, R, t);
-- 
GitLab