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

Code tidy

parent 775cb69b
No related branches found
No related tags found
1 merge request!37Resolves #83 net performance, partially
Pipeline #11541 failed
......@@ -64,15 +64,11 @@ NetSource::~NetSource() {
void NetSource::_recv(const vector<unsigned char> &jpg, const vector<unsigned char> &d) {
cv::Mat tmp_rgb, tmp_depth;
// Decode in temporary buffers to prevent long locks
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_--;
......@@ -135,6 +131,7 @@ void NetSource::_updateURI() {
}
bool NetSource::grab() {
// Send one frame before end to prevent unwanted pause
if (N_ <= 1) {
N_ = 10;
if (!host_->getNet()->send(peer_, "get_stream", *host_->get<string>("uri"), 10, 0, host_->getNet()->id(), *host_->get<string>("uri"))) {
......
......@@ -112,7 +112,7 @@ void Streamer::_addClient(const string &source, int N, int rate, const ftl::UUID
if (rate < 0 || rate >= 10) return;
if (N < 0 || N > ftl::rgbd::kMaxFrames) return;
LOG(INFO) << "Adding Stream Peer: " << peer.to_string();
DLOG(INFO) << "Adding Stream Peer: " << peer.to_string();
StreamSource *s = sources_[source];
for (int i=0; i<s->clients[rate].size(); i++) {
......@@ -130,7 +130,6 @@ void Streamer::_addClient(const string &source, int N, int rate, const ftl::UUID
c.txcount = 0;
c.txmax = N;
//unique_lock<shared_mutex> ulk(s->mutex);
s->clients[rate].push_back(c);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment