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
......@@ -83,6 +83,8 @@ static void run() {
while (disp.active()) {
Mat idepth;
net.broadcast("grab");
unique_lock<mutex> lk(m);
if (depth.cols > 0) {
......
......@@ -108,11 +108,24 @@ static void run(const string &file) {
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
auto disparity = Disparity::create(config["disparity"]);
if (!disparity) LOG(FATAL) << "Unknown disparity algorithm : " << config["disparity"];
Mat l, r, disp;
Mat pl, pdisp;
vector<unsigned char> rgb_buf;
vector<unsigned char> d_buf;
......@@ -132,9 +145,11 @@ static void run(const string &file) {
// Pipeline for disparity
pool.push([&](int id) {
auto start = std::chrono::high_resolution_clock::now();
// 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
//sync->feed(ftl::LEFT, l, lsrc->getTimestamp());
......@@ -144,7 +159,9 @@ static void run(const string &file) {
//sync->get(ftl::LEFT, l);
//sync->get(ftl::RIGHT, r);
auto start = std::chrono::high_resolution_clock::now();
disparity->compute(l, r, disp);
datalk.unlock();
unique_lock<mutex> lk(m);
jobs++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment