diff --git a/reconstruct/src/main.cpp b/reconstruct/src/main.cpp index 806e17bb9336d40bca4164c5ab83ef297298e772..8b7035dfccdf897a715e11a6c1f65881fcf01450 100644 --- a/reconstruct/src/main.cpp +++ b/reconstruct/src/main.cpp @@ -115,7 +115,7 @@ static void process_options(const map<string, string> &opts) { static void run(const string &file) { Universe net(config["net"]); - Mat rgb, depth; + Mat rgb, depth, Q; mutex m; // Make sure connections are complete @@ -152,6 +152,14 @@ static void run(const string &file) { cv::imshow("RGB", rgb); } if (depth.cols > 0) { + if (Q.rows == 0) { + auto buf = net.findOne<vector<unsigned char>>((string)config["source"]+"/calibration"); + if (buf) { + Q = Mat(cv::Size(4,4), CV_32F); + memcpy((*buf).data(), Q.data, (*buf).size()); + LOG(INFO) << "Have calibration"; + } + } depth.convertTo(idepth, CV_8U, 255.0f / 256.0f); // TODO(nick) applyColorMap(idepth, idepth, cv::COLORMAP_JET); cv::imshow("Depth", idepth); diff --git a/vision/src/main.cpp b/vision/src/main.cpp index 31e1c4100689d47ed0a7b0b64cca45336b2a915f..16e1bc6ae368a3658e54f74f808eeb96c88d1bb7 100644 --- a/vision/src/main.cpp +++ b/vision/src/main.cpp @@ -139,9 +139,21 @@ static void run(const string &file) { Calibrate calibrate(lsrc, config["calibration"]); if (config["calibrate"]) calibrate.recalibrate(); if (!calibrate.isCalibrated()) LOG(WARNING) << "Cameras are not calibrated!"; + + // Allow remote users to access camera calibration matrix + net.bind(string("ftl://utu.fi/")+(string)config["stream"]["name"]+string("/rgb-d/calibration"), [&calibrate]() -> vector<unsigned char> { + vector<unsigned char> buf; + cv::Mat Q_32F; + calibrate.getQ().convertTo(Q_32F, CV_32F); + + buf.resize(Q_32F.step*Q_32F.rows); + memcpy(Q_32F.data, buf.data(), buf.size()); + return buf; + }); // Choose and configure disparity algorithm auto disparity = Disparity::create(config["disparity"]); + if (!disparity) LOG(FATAL) << "Unknown disparity algorithm : " << config["disparity"]; Mat l, r, disp; @@ -160,6 +172,7 @@ static void run(const string &file) { sync->get(ftl::LEFT, l); sync->get(ftl::RIGHT, r); + // TODO(nick) Pipeline this disparity->compute(l, r, disp); // Send RGB+Depth images for local rendering