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

Send calibration data over network

parent e775bff7
Branches
Tags
No related merge requests found
......@@ -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);
......
......@@ -140,8 +140,20 @@ static void run(const string &file) {
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment