diff --git a/components/rgbd-sources/src/net.cpp b/components/rgbd-sources/src/net.cpp index 4c606aa36c802db14c5a0a0291775002d5a45e87..ac7bc8553da8a8b7e417a26787f72f32b6c91c3d 100644 --- a/components/rgbd-sources/src/net.cpp +++ b/components/rgbd-sources/src/net.cpp @@ -64,20 +64,19 @@ NetSource::~NetSource() { void NetSource::_recv(const vector<unsigned char> &jpg, const vector<unsigned char> &d) { cv::Mat tmp_rgb, tmp_depth; - auto start = std::chrono::high_resolution_clock::now(); cv::imdecode(jpg, cv::IMREAD_COLOR, &tmp_rgb); //Mat(rgb_.size(), CV_16UC1); cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth); + auto start = std::chrono::high_resolution_clock::now(); unique_lock<shared_mutex> lk(host_->mutex()); + std::chrono::duration<double> elapsed = + std::chrono::high_resolution_clock::now() - start; + LOG(INFO) << "ELAPSED LOCK: " << elapsed.count(); rgb_ = tmp_rgb; tmp_depth.convertTo(depth_, CV_32FC1, 1.0f/(16.0f*100.0f)); N_--; lk.unlock(); - - std::chrono::duration<double> elapsed = - std::chrono::high_resolution_clock::now() - start; - LOG(INFO) << "ELAPSED DECODE: " << elapsed.count(); } void NetSource::setPose(const Eigen::Matrix4f &pose) { diff --git a/components/rgbd-sources/src/streamer.cpp b/components/rgbd-sources/src/streamer.cpp index 00a370fc6c8222514fc0ad6e0421c21692c82376..eeb3fb82727f8066eb2a9a5088facece54e64bcb 100644 --- a/components/rgbd-sources/src/streamer.cpp +++ b/components/rgbd-sources/src/streamer.cpp @@ -291,6 +291,12 @@ void Streamer::_schedule() { }); } + // Do some jobs in this thread, might as well... + std::function<void(int)> j; + while ((bool)(j=pool_.pop())) { + j(-1); + } + // Wait for all jobs to complete before finishing frame unique_lock<mutex> lk(job_mtx); job_cv.wait(lk, [&jobs]{ return jobs == 0; });