From 7fbcf3a7792c599a3ca5455260f791443f599d91 Mon Sep 17 00:00:00 2001
From: Sebastian Hahta <joseha@utu.fi>
Date: Mon, 27 May 2019 11:30:00 +0300
Subject: [PATCH] Use temporary Mat when capturing a frame.

---
 components/rgbd-sources/src/calibrate.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/components/rgbd-sources/src/calibrate.cpp b/components/rgbd-sources/src/calibrate.cpp
index e1b1512d6..0134afbcd 100644
--- a/components/rgbd-sources/src/calibrate.cpp
+++ b/components/rgbd-sources/src/calibrate.cpp
@@ -493,14 +493,15 @@ bool Calibrate::_recalibrate(vector<vector<Point2f>> *imagePoints,
 }
 
 bool Calibrate::undistort(cv::Mat &l, cv::Mat &r) {
-	local_->get(l, r);
+	Mat l_tmp, r_tmp;
+	local_->get(l_tmp, r_tmp);
 	if (!calibrated_) return false;
-	if (l.empty() || r.empty()) {
+	if (l_tmp.empty() || r_tmp.empty()) {
 		LOG(ERROR) << "l/r empty in undistort()!!!";
 		return false;
 	}
-	remap(l, l, map1_[0], map2_[0], INTER_LINEAR);
-	if (local_->isStereo()) remap(r, r, map1_[1], map2_[1], INTER_LINEAR);
+	remap(l_tmp, l, map1_[0], map2_[0], INTER_LINEAR);
+	if (local_->isStereo()) remap(r_tmp, r, map1_[1], map2_[1], INTER_LINEAR);
 	return true;
 }
 
-- 
GitLab