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

Improve source restore and fix strip bug

parent cb8a4b71
Branches
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28334 passed
...@@ -294,6 +294,11 @@ int main(int argc, char **argv) { ...@@ -294,6 +294,11 @@ int main(int argc, char **argv) {
std::cout << "FTL Vision Node " << FTL_VERSION_LONG << std::endl; std::cout << "FTL Vision Node " << FTL_VERSION_LONG << std::endl;
auto root = ftl::configure(argc, argv, "vision_default"); auto root = ftl::configure(argc, argv, "vision_default");
root->restore("root", {
"uri",
"fps"
});
// Use other GPU if available. // Use other GPU if available.
//ftl::cuda::setDevice(ftl::cuda::deviceCount()-1); //ftl::cuda::setDevice(ftl::cuda::deviceCount()-1);
......
...@@ -657,14 +657,18 @@ Configurable *ftl::config::configure(ftl::config::json_t &cfg) { ...@@ -657,14 +657,18 @@ Configurable *ftl::config::configure(ftl::config::json_t &cfg) {
// Remove all $ keys from json // Remove all $ keys from json
static void stripJSON(nlohmann::json &j) { static void stripJSON(nlohmann::json &j) {
for(auto &el : j.items()) { auto items = j.items();
for(auto i=items.begin(); i != items.end(); ) {
auto &el = *i;
if (el.key()[0] == '$') { if (el.key()[0] == '$') {
++i;
j.erase(el.key()); j.erase(el.key());
continue; continue;
} }
if (el.value().is_structured()) { if (el.value().is_structured()) {
stripJSON(el.value()); stripJSON(el.value());
} }
++i;
} }
} }
......
...@@ -200,7 +200,7 @@ void URI::setAttribute(const string &key, int value) { ...@@ -200,7 +200,7 @@ void URI::setAttribute(const string &key, int value) {
} }
void URI::to_json(nlohmann::json &json) { void URI::to_json(nlohmann::json &json) {
std::string uri = getBaseURI(); std::string uri = to_string();
if (m_frag.size() > 0) uri += std::string("#") + getFragment(); if (m_frag.size() > 0) uri += std::string("#") + getFragment();
json["uri"] = uri; json["uri"] = uri;
......
...@@ -149,7 +149,9 @@ void Source::reset() { ...@@ -149,7 +149,9 @@ void Source::reset() {
auto uristr = get<string>("uri"); auto uristr = get<string>("uri");
if (!uristr) return; if (!uristr) return;
restore(*uristr, { ftl::URI uri(*uristr);
restore(uri.getBaseURI(), {
"min_depth", "min_depth",
"max_depth", "max_depth",
"name", "name",
...@@ -161,6 +163,9 @@ void Source::reset() { ...@@ -161,6 +163,9 @@ void Source::reset() {
"feed", "feed",
"pipeline" "pipeline"
}); });
uri.to_json(getConfig());
impl_ = createImplementation(*uristr, this); impl_ = createImplementation(*uristr, this);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment