Skip to content
Snippets Groups Projects
Commit 6f7f351c authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Have streamer do some jobs directly

parent 37ebbb50
No related branches found
No related tags found
1 merge request!37Resolves #83 net performance, partially
Pipeline #11531 passed
...@@ -64,20 +64,19 @@ NetSource::~NetSource() { ...@@ -64,20 +64,19 @@ NetSource::~NetSource() {
void NetSource::_recv(const vector<unsigned char> &jpg, const vector<unsigned char> &d) { void NetSource::_recv(const vector<unsigned char> &jpg, const vector<unsigned char> &d) {
cv::Mat tmp_rgb, tmp_depth; cv::Mat tmp_rgb, tmp_depth;
auto start = std::chrono::high_resolution_clock::now();
cv::imdecode(jpg, cv::IMREAD_COLOR, &tmp_rgb); cv::imdecode(jpg, cv::IMREAD_COLOR, &tmp_rgb);
//Mat(rgb_.size(), CV_16UC1); //Mat(rgb_.size(), CV_16UC1);
cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth); cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth);
auto start = std::chrono::high_resolution_clock::now();
unique_lock<shared_mutex> lk(host_->mutex()); 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; rgb_ = tmp_rgb;
tmp_depth.convertTo(depth_, CV_32FC1, 1.0f/(16.0f*100.0f)); tmp_depth.convertTo(depth_, CV_32FC1, 1.0f/(16.0f*100.0f));
N_--; N_--;
lk.unlock(); 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) { void NetSource::setPose(const Eigen::Matrix4f &pose) {
......
...@@ -291,6 +291,12 @@ void Streamer::_schedule() { ...@@ -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 // Wait for all jobs to complete before finishing frame
unique_lock<mutex> lk(job_mtx); unique_lock<mutex> lk(job_mtx);
job_cv.wait(lk, [&jobs]{ return jobs == 0; }); job_cv.wait(lk, [&jobs]{ return jobs == 0; });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment