From 91eac3b0b19c0132f6d361b9dbf6a9d26d553d6e Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 5 Jun 2019 21:48:34 +0300
Subject: [PATCH] Fix for multi thread call to grab

---
 components/rgbd-sources/src/stereovideo_source.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/components/rgbd-sources/src/stereovideo_source.cpp b/components/rgbd-sources/src/stereovideo_source.cpp
index 1b2248679..4e8da1d06 100644
--- a/components/rgbd-sources/src/stereovideo_source.cpp
+++ b/components/rgbd-sources/src/stereovideo_source.cpp
@@ -112,12 +112,15 @@ static void disparityToDepth(const cv::Mat &disparity, cv::Mat &depth, const cv:
 }
 
 void StereoVideoSource::grab() {
+	// TODO(Nick) find a way to move this to last part ... but grab can't
+	// be called twice by different threads and it is currently
+	// FIXME Call to grab from multiple threads
+	unique_lock<mutex> lk(mutex_);
 	calib_->rectified(left_, right_);
 
 	cv::Mat disp;
 	disp_->compute(left_, right_, disp);
 
-	unique_lock<mutex> lk(mutex_);
 	left_.copyTo(rgb_);
 	disparityToDepth(disp, depth_, calib_->getQ());
 }
-- 
GitLab