From 055c6a23d079a3b877e6596f1e5a22041a9745b7 Mon Sep 17 00:00:00 2001 From: TinyOh Date: Wed, 20 Feb 2019 16:31:32 +0800 Subject: [PATCH] fix(thread): ProcessNativeStream --- src/mynteye/api/synthetic.cc | 8 +++----- src/mynteye/api/synthetic.h | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mynteye/api/synthetic.cc b/src/mynteye/api/synthetic.cc index a73d280..1830e67 100644 --- a/src/mynteye/api/synthetic.cc +++ b/src/mynteye/api/synthetic.cc @@ -583,14 +583,12 @@ void Synthetic::InitProcessors() { void Synthetic::ProcessNativeStream( const Stream &stream, const api::StreamData &data) { if (stream == Stream::LEFT || stream == Stream::RIGHT) { + std::unique_lock lk(mtx_left_right_ready_); static api::StreamData left_data, right_data; - cv::Mat tmp1, tmp2; if (stream == Stream::LEFT) { left_data = data; - tmp1 = left_data.frame.clone(); } else if (stream == Stream::RIGHT) { right_data = data; - tmp2 = right_data.frame.clone(); } if (left_data.img && right_data.img && left_data.img->frame_id == right_data.img->frame_id) { @@ -607,8 +605,8 @@ void Synthetic::ProcessNativeStream( processor = find_processor(processor_); } processor->Process(ObjMat2{ - tmp1, left_data.frame_id, left_data.img, - tmp2, right_data.frame_id, right_data.img}); + left_data.frame, left_data.frame_id, left_data.img, + right_data.frame, right_data.frame_id, right_data.img}); } return; } diff --git a/src/mynteye/api/synthetic.h b/src/mynteye/api/synthetic.h index e39088b..29a9548 100644 --- a/src/mynteye/api/synthetic.h +++ b/src/mynteye/api/synthetic.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "mynteye/api/api.h" #include "mynteye/api/config.h" @@ -132,6 +133,7 @@ class Synthetic { std::shared_ptr plugin_; CalibrationModel calib_model_; + std::mutex mtx_left_right_ready_; std::shared_ptr intr_left_; std::shared_ptr intr_right_;