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

Improve vision restore

parent 269d0cc3
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
...@@ -58,6 +58,8 @@ using std::chrono::milliseconds; ...@@ -58,6 +58,8 @@ using std::chrono::milliseconds;
using cv::Mat; using cv::Mat;
using json = nlohmann::json; using json = nlohmann::json;
static bool quiet = false;
static void run(ftl::Configurable *root) { static void run(ftl::Configurable *root) {
Universe *net = ftl::create<Universe>(root, "net"); Universe *net = ftl::create<Universe>(root, "net");
...@@ -117,10 +119,8 @@ static void run(ftl::Configurable *root) { ...@@ -117,10 +119,8 @@ static void run(ftl::Configurable *root) {
auto paths = root->get<vector<string>>("paths"); auto paths = root->get<vector<string>>("paths");
string file = ""; string file = "";
//if (paths && (*paths).size() > 0) file = (*paths)[(*paths).size()-1];
for (auto &x : *paths) { for (auto &x : *paths) {
//LOG(INFO) << "PATH - " << x;
if (x != "") { if (x != "") {
ftl::URI uri(x); ftl::URI uri(x);
if (uri.isValid()) { if (uri.isValid()) {
...@@ -150,7 +150,7 @@ static void run(ftl::Configurable *root) { ...@@ -150,7 +150,7 @@ static void run(ftl::Configurable *root) {
ftl::audio::Source *audioSrc = ftl::create<ftl::audio::Source>(root, "audio_test"); ftl::audio::Source *audioSrc = ftl::create<ftl::audio::Source>(root, "audio_test");
ftl::data::Pool pool(2,5); ftl::data::Pool pool(root->value("mempool_min", 2),root->value("mempool_max", 5));
auto *creator = new ftl::streams::IntervalSourceBuilder(&pool, 0, {source, audioSrc}); auto *creator = new ftl::streams::IntervalSourceBuilder(&pool, 0, {source, audioSrc});
std::shared_ptr<ftl::streams::BaseBuilder> creatorptr(creator); std::shared_ptr<ftl::streams::BaseBuilder> creatorptr(creator);
...@@ -184,6 +184,11 @@ static void run(ftl::Configurable *root) { ...@@ -184,6 +184,11 @@ static void run(ftl::Configurable *root) {
float latency = 0.0f; float latency = 0.0f;
int64_t stats_time = 0; int64_t stats_time = 0;
quiet = root->value("quiet", false);
root->on("quiet", [root](const ftl::config::Event &e) {
quiet = root->value("quiet", false);
});
auto *pipeline = ftl::config::create<ftl::operators::Graph>(root, "pipeline"); auto *pipeline = ftl::config::create<ftl::operators::Graph>(root, "pipeline");
pipeline->append<ftl::operators::DetectAndTrack>("facedetection")->value("enabled", false); pipeline->append<ftl::operators::DetectAndTrack>("facedetection")->value("enabled", false);
pipeline->append<ftl::operators::ArUco>("aruco")->value("enabled", false); pipeline->append<ftl::operators::ArUco>("aruco")->value("enabled", false);
...@@ -224,7 +229,7 @@ static void run(ftl::Configurable *root) { ...@@ -224,7 +229,7 @@ static void run(ftl::Configurable *root) {
++frames; ++frames;
latency += float(ftl::timer::get_time() - fs->timestamp()); latency += float(ftl::timer::get_time() - fs->timestamp());
if (--stats_count <= 0) { if (!quiet && --stats_count <= 0) {
latency /= float(frames); latency /= float(frames);
int64_t nowtime = ftl::timer::get_time(); int64_t nowtime = ftl::timer::get_time();
stats_time = nowtime - stats_time; stats_time = nowtime - stats_time;
...@@ -253,18 +258,12 @@ static void run(ftl::Configurable *root) { ...@@ -253,18 +258,12 @@ static void run(ftl::Configurable *root) {
// Start the timed generation of frames // Start the timed generation of frames
creator->start(); creator->start();
// TODO: TEMPORARY
/*ftl::audio::Source *audioSrc = ftl::create<ftl::audio::Source>(root, "audio_test");
audioSrc->onFrameSet([sender](ftl::audio::FrameSet &fs) {
sender->post(fs);
return true;
}); */
// Only now start listening for connections
net->start(); net->start();
LOG(INFO) << "Running..."; LOG(INFO) << "Running...";
ftl::timer::start(true); ftl::timer::start(true); // Blocks
LOG(INFO) << "Stopping..."; LOG(INFO) << "Stopping...";
ctrl.stop(); ctrl.stop();
...@@ -279,7 +278,6 @@ static void run(ftl::Configurable *root) { ...@@ -279,7 +278,6 @@ static void run(ftl::Configurable *root) {
delete audioSrc; delete audioSrc;
delete outstream; delete outstream;
//delete source; // TODO(Nick) Add ftl::destroy
delete net; delete net;
} }
...@@ -292,11 +290,23 @@ int main(int argc, char **argv) { ...@@ -292,11 +290,23 @@ int main(int argc, char **argv) {
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
#endif #endif
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", "uri",
"fps" "fps",
"time_master",
"time_peer",
"quiet"
});
root->value("restart", 0);
// Allow config controlled restart
root->on("restart", [root](const ftl::config::Event &e) {
auto val = root->get<int>("restart");
if (val) {
ftl::exit_code = *val;
ftl::running = false;
}
}); });
// Use other GPU if available. // Use other GPU if available.
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <optional> #include <optional>
#include <unordered_set>
namespace ftl { namespace ftl {
...@@ -38,7 +39,7 @@ std::optional<std::string> locateFile(const std::string &name); ...@@ -38,7 +39,7 @@ std::optional<std::string> locateFile(const std::string &name);
std::map<std::string, std::string> read_options(char ***argv, int *argc); std::map<std::string, std::string> read_options(char ***argv, int *argc);
Configurable *configure(int argc, char **argv, const std::string &root); Configurable *configure(int argc, char **argv, const std::string &root, const std::unordered_set<std::string> &restoreable={});
Configurable *configure(json_t &); Configurable *configure(json_t &);
......
...@@ -836,7 +836,7 @@ template void ftl::config::setJSON<float>(nlohmann::json *config, const std::str ...@@ -836,7 +836,7 @@ template void ftl::config::setJSON<float>(nlohmann::json *config, const std::str
template void ftl::config::setJSON<int>(nlohmann::json *config, const std::string &name, int value); template void ftl::config::setJSON<int>(nlohmann::json *config, const std::string &name, int value);
template void ftl::config::setJSON<std::string>(nlohmann::json *config, const std::string &name, std::string value); template void ftl::config::setJSON<std::string>(nlohmann::json *config, const std::string &name, std::string value);
Configurable *ftl::config::configure(int argc, char **argv, const std::string &root) { Configurable *ftl::config::configure(int argc, char **argv, const std::string &root, const std::unordered_set<std::string> &restoreable) {
loguru::g_preamble_date = false; loguru::g_preamble_date = false;
loguru::g_preamble_uptime = false; loguru::g_preamble_uptime = false;
loguru::g_preamble_thread = false; loguru::g_preamble_thread = false;
...@@ -878,6 +878,7 @@ Configurable *ftl::config::configure(int argc, char **argv, const std::string &r ...@@ -878,6 +878,7 @@ Configurable *ftl::config::configure(int argc, char **argv, const std::string &r
//root_config = rootcfg->getConfig(); //root_config = rootcfg->getConfig();
rootCFG = rootcfg; rootCFG = rootcfg;
rootcfg->set("paths", paths); rootcfg->set("paths", paths);
rootcfg->restore("root", restoreable);
process_options(rootcfg, options); process_options(rootcfg, options);
if (rootcfg->get<int>("profiler")) { if (rootcfg->get<int>("profiler")) {
......
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