diff --git a/components/rgbd-sources/src/sources/stereovideo/opencv.cpp b/components/rgbd-sources/src/sources/stereovideo/opencv.cpp index 08e2a0f7523881e7a4e00c644a12994326d73b9a..cdb9088a4c186ea79a0d91be6a6d10f2b0fc6ad3 100644 --- a/components/rgbd-sources/src/sources/stereovideo/opencv.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/opencv.cpp @@ -347,32 +347,32 @@ bool OpenCVDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cud if (!camera_a_) return false; - std::future<bool> future_b; + //std::future<bool> future_b; if (camera_b_) { - future_b = std::move(ftl::pool.push([this,&rfull,&r,c,&r_out,&r_hres_out,&stream](int id) { + //future_b = std::move(ftl::pool.push([this,&rfull,&r,c,&r_out,&r_hres_out,&stream](int id) { if (!camera_b_->retrieve(frame_r_)) { LOG(ERROR) << "Unable to read frame from camera B"; return false; + } else { + cv::cvtColor(frame_r_, rtmp2_, cv::COLOR_BGR2BGRA); + + //if (stereo_) { + c->rectify(rtmp2_, rfull, Channel::Right); + + if (hasHigherRes()) { + // TODO: Use threads? + cv::resize(rfull, r, r.size(), 0.0, 0.0, interpolation_); + r_hres_out = rfull; + } + else { + r_hres_out = Mat(); + } + //} + + r_out.upload(r, stream); } - - cv::cvtColor(frame_r_, rtmp2_, cv::COLOR_BGR2BGRA); - - //if (stereo_) { - c->rectify(rtmp2_, rfull, Channel::Right); - - if (hasHigherRes()) { - // TODO: Use threads? - cv::resize(rfull, r, r.size(), 0.0, 0.0, interpolation_); - r_hres_out = rfull; - } - else { - r_hres_out = Mat(); - } - //} - - r_out.upload(r, stream); - return true; - })); + //return true; + //})); } if (camera_b_) { @@ -431,10 +431,10 @@ bool OpenCVDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cud cv::imencode(".jpg", thumb, thumbdata, params); } - if (camera_b_) { + //if (camera_b_) { //FTL_Profile("WaitCamB", 0.05); - future_b.wait(); - } + //future_b.wait(); + //} return true; } diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp index 48999538562bd26286fb258e7b131dc3d1ba4f74..9f1d33a1456b6485e2ac5435dec7f2c87f1ce8bd 100644 --- a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp @@ -283,47 +283,49 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda try { FTL_Profile("Frame Retrieve", 0.005); - std::future<bool> future_b; + //std::future<bool> future_b; + bool res_r = false; if (rcam_) { - future_b = std::move(ftl::pool.push([this,&rfull,&r,&l,c,&r_out,&h_r,&stream](int id) { + //future_b = std::move(ftl::pool.push([this,&rfull,&r,&l,c,&r_out,&h_r,&stream](int id) { Pylon::CGrabResultPtr result_right; - if (!_retrieveFrames(result_right, rcam_)) return false; + if (_retrieveFrames(result_right, rcam_)) { - cv::Mat wrap_right( - result_right->GetHeight(), - result_right->GetWidth(), - CV_8UC1, - (uint8_t*)result_right->GetBuffer()); + cv::Mat wrap_right( + result_right->GetHeight(), + result_right->GetWidth(), + CV_8UC1, + (uint8_t*)result_right->GetBuffer()); - { - FTL_Profile("Bayer Colour (R)", 0.005); - cv::cvtColor(wrap_right, rtmp2_, cv::COLOR_BayerRG2BGRA); - } - - //if (isStereo()) { - FTL_Profile("Rectify and Resize (R)", 0.005); - c->rectify(rtmp2_, rfull, Channel::Right); - - if (hasHigherRes()) { - cv::resize(rfull, r, r.size(), 0.0, 0.0, interpolation_); - h_r = rfull; + { + FTL_Profile("Bayer Colour (R)", 0.005); + cv::cvtColor(wrap_right, rtmp2_, cv::COLOR_BayerRG2BGRA); } - else { - h_r = Mat(); - } - //} - r_out.upload(r, stream); - return true; - })); + //if (isStereo()) { + FTL_Profile("Rectify and Resize (R)", 0.005); + c->rectify(rtmp2_, rfull, Channel::Right); + + if (hasHigherRes()) { + cv::resize(rfull, r, r.size(), 0.0, 0.0, interpolation_); + h_r = rfull; + } + else { + h_r = Mat(); + } + //} + + r_out.upload(r, stream); + res_r = true; + } + //})); } Pylon::CGrabResultPtr result_left; if (!_retrieveFrames(result_left, lcam_)) { if (rcam_) { - future_b.wait(); + //future_b.wait(); } return false; } @@ -357,8 +359,9 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda l_out.upload(l, stream); if (rcam_) { - future_b.wait(); - if (!future_b.get()) return false; + //future_b.wait(); + //if (!future_b.get()) return false; + if (!res_r) return false; } } catch (const GenericException &e) {