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

Configurable aliasing and non stereo rectify bug fix

parent aeae3885
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28137 failed
......@@ -79,6 +79,11 @@ json_t &resolveWait(const std::string &);
*/
Configurable *find(const std::string &uri);
/**
* Add an alternative URI for a configurable.
*/
void alias(const std::string &uri, Configurable *cfg);
/**
* Get all configurables that contain a specified tag. Tags are given under the
* "tags" property as an array of strings, but only during configurable
......
......@@ -238,6 +238,7 @@ static bool mergeConfig(const string path) {
static std::map<std::string, json_t*> config_index;
static std::map<std::string, ftl::Configurable*> config_instance;
static std::map<std::string, ftl::Configurable*> config_alias;
static std::map<std::string, std::vector<ftl::Configurable*>> tag_index;
/*
......@@ -269,10 +270,18 @@ ftl::Configurable *ftl::config::find(const std::string &uri) {
}
auto ix = config_instance.find(actual_uri);
if (ix == config_instance.end()) return nullptr;
if (ix == config_instance.end()) {
auto ix = config_alias.find(actual_uri);
if (ix == config_instance.end()) return nullptr;
else return (*ix).second;
}
else return (*ix).second;
}
void ftl::config::alias(const std::string &uri, Configurable *cfg) {
config_alias[uri] = cfg;
}
const std::vector<Configurable*> &ftl::config::findByTag(const std::string &tag) {
return tag_index[tag];
}
......
......@@ -181,6 +181,7 @@ double StereoRectification::baseline() {
}
double StereoRectification::doff() {
if (!enabled_ || !valid_) return 0.0;
return -(Q_.at<double>(3,3) * baseline_);
}
......
......@@ -172,6 +172,8 @@ void StereoVideoSource::updateParameters(ftl::rgbd::Frame &frame) {
calibration_change_ = frame.onChange(Channel::CalibrationData, [this]
(ftl::data::Frame& frame, ftl::codecs::Channel) {
if (!lsrc_->isStereo()) return true;
auto &change = frame.get<ftl::calibration::CalibrationData>(Channel::CalibrationData);
try {
change.writeFile(fname_calib_);
......
......@@ -3,6 +3,11 @@
#define LOGURU_REPLACE_GLOG 1
#include <loguru.hpp>
#ifndef WIN32
#include <unistd.h>
#include <limits.h>
#endif
using ftl::stream::Net;
using ftl::codecs::StreamPacket;
using ftl::codecs::Packet;
......@@ -229,6 +234,24 @@ bool Net::begin() {
// TODO: Register URI as available.
host_ = true;
// Alias the URI to the configurable if not already
// Allows the URI to be used to get config data.
if (ftl::config::find(uri_) == nullptr) {
ftl::config::alias(uri_, this);
}
// Automatically set name if missing
if (!get<std::string>("name")) {
char hostname[1024] = {0};
#ifdef WIN32
GetComputerName(hostname, 1024);
#else
gethostname(hostname, 1024);
#endif
set("name", std::string(hostname));
}
net_->broadcast("add_stream", uri_);
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment