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

Lock after decode

parent efa270be
No related branches found
No related tags found
1 merge request!37Resolves #83 net performance, partially
Pipeline #11528 passed
...@@ -62,13 +62,17 @@ NetSource::~NetSource() { ...@@ -62,13 +62,17 @@ 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) {
unique_lock<shared_mutex> lk(host_->mutex()); cv::Mat tmp_rgb, tmp_depth;
auto start = std::chrono::high_resolution_clock::now(); auto start = std::chrono::high_resolution_clock::now();
cv::imdecode(jpg, cv::IMREAD_COLOR, &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, &depth_); cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth);
depth_.convertTo(depth_, CV_32FC1, 1.0f/(16.0f*100.0f));
unique_lock<shared_mutex> lk(host_->mutex());
rgb_ = tmp_rgb;
tmp_depth.convertTo(depth_, CV_32FC1, 1.0f/(16.0f*100.0f));
lk.unlock();
std::chrono::duration<double> elapsed = std::chrono::duration<double> elapsed =
std::chrono::high_resolution_clock::now() - start; std::chrono::high_resolution_clock::now() - start;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment