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

Use grab to sync cam capture

parent a474c47c
No related branches found
No related tags found
No related merge requests found
Pipeline #10500 passed
...@@ -84,6 +84,8 @@ static void run() { ...@@ -84,6 +84,8 @@ static void run() {
while (disp.active()) { while (disp.active()) {
Mat idepth; Mat idepth;
net.broadcast("grab");
unique_lock<mutex> lk(m); unique_lock<mutex> lk(m);
if (depth.cols > 0) { if (depth.cols > 0) {
// If no calibration data then get it from the remote machine // If no calibration data then get it from the remote machine
......
...@@ -108,11 +108,24 @@ static void run(const string &file) { ...@@ -108,11 +108,24 @@ static void run(const string &file) {
return buf; return buf;
}); });
Mat l, r, disp;
bool grabbed = false;
mutex datam;
condition_variable datacv;
net.bind("grab", [&calibrate,&l,&r,&datam,&datacv,&grabbed]() -> void {
// LOG(INFO) << "GRAB";
unique_lock<mutex> datalk(datam);
if (grabbed) return;
calibrate.rectified(l, r);
grabbed = true;
datacv.notify_one();
});
// Choose and configure disparity algorithm // Choose and configure disparity algorithm
auto disparity = Disparity::create(config["disparity"]); auto disparity = Disparity::create(config["disparity"]);
if (!disparity) LOG(FATAL) << "Unknown disparity algorithm : " << config["disparity"]; if (!disparity) LOG(FATAL) << "Unknown disparity algorithm : " << config["disparity"];
Mat l, r, disp;
Mat pl, pdisp; Mat pl, pdisp;
vector<unsigned char> rgb_buf; vector<unsigned char> rgb_buf;
vector<unsigned char> d_buf; vector<unsigned char> d_buf;
...@@ -132,9 +145,11 @@ static void run(const string &file) { ...@@ -132,9 +145,11 @@ static void run(const string &file) {
// Pipeline for disparity // Pipeline for disparity
pool.push([&](int id) { pool.push([&](int id) {
auto start = std::chrono::high_resolution_clock::now();
// Read calibrated images. // Read calibrated images.
calibrate.rectified(l, r); //calibrate.rectified(l, r);
unique_lock<mutex> datalk(datam);
datacv.wait(datalk, [&grabbed](){ return grabbed; });
grabbed = false;
// Feed into sync buffer and network forward // Feed into sync buffer and network forward
//sync->feed(ftl::LEFT, l, lsrc->getTimestamp()); //sync->feed(ftl::LEFT, l, lsrc->getTimestamp());
...@@ -144,7 +159,9 @@ static void run(const string &file) { ...@@ -144,7 +159,9 @@ static void run(const string &file) {
//sync->get(ftl::LEFT, l); //sync->get(ftl::LEFT, l);
//sync->get(ftl::RIGHT, r); //sync->get(ftl::RIGHT, r);
auto start = std::chrono::high_resolution_clock::now();
disparity->compute(l, r, disp); disparity->compute(l, r, disp);
datalk.unlock();
unique_lock<mutex> lk(m); unique_lock<mutex> lk(m);
jobs++; jobs++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment