From 52f0f7b8b70ffba46bc925089b6c0b6ced24bab0 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Sun, 2 Jun 2019 17:44:15 +0300 Subject: [PATCH] Source stream listings --- applications/gui/src/main.cpp | 32 +++++++++++++++++++++++++-- applications/reconstruct/src/main.cpp | 5 ++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/applications/gui/src/main.cpp b/applications/gui/src/main.cpp index c4c171045..55dff3656 100644 --- a/applications/gui/src/main.cpp +++ b/applications/gui/src/main.cpp @@ -12,6 +12,8 @@ #include <nanogui/window.h> #include <nanogui/layout.h> #include <nanogui/imageview.h> +#include <nanogui/combobox.h> +#include <nanogui/label.h> using ftl::config; using std::string; @@ -103,6 +105,18 @@ class VirtualCameraView : public nanogui::ImageView { } } + bool keyboardEvent(int key, int scancode, int action, int modifiers) { + LOG(INFO) << "Key press" << key << " - " << action; + if (key == 81 || key == 83) { + // TODO Should rotate around lookAt object, but requires correct depth + Eigen::Quaternion<float> q; q = Eigen::AngleAxis<float>((key == 81) ? 0.01f : -0.01f, up_); + eye_ = (q * (eye_ - centre_)) + centre_; + } else if (key == 84 || key == 82) { + float scalar = (key == 84) ? 0.99f : 1.01f; + eye_ = ((eye_ - centre_) * scalar) + centre_; + } + } + void draw(NVGcontext *ctx) { //net_->broadcast("grab"); if (src_) { @@ -114,7 +128,6 @@ class VirtualCameraView : public nanogui::ImageView { src_->grab(); src_->getRGBD(rgb, depth); if (rgb.rows > 0) { - LOG(INFO) << "Update texture"; texture_.update(rgb); bindImage(texture_.texture()); } @@ -148,7 +161,7 @@ class FTLApplication : public nanogui::Screen { //auto &cam = sources_.emplace_back(); //cam.source = in; - auto imageWindow = new Window(this, "Source"); + auto imageWindow = new Window(this, in->getURI()); imageWindow->setPosition(Eigen::Vector2i(710, 15)); imageWindow->setLayout(new GroupLayout()); imageWindow->setSize(Vector2i(400,400)); @@ -164,6 +177,16 @@ class FTLApplication : public nanogui::Screen { } } + auto window = new Window(this, "Sources"); + window->setLayout(new GroupLayout()); + + new Label(window, "Select source","sans-bold"); + auto available = net->findAll<string>("list_streams"); + auto select = new ComboBox(window, available); + select->setCallback([this,&available](int ix) { + LOG(INFO) << "Change source: " << ix; + }); + setVisible(true); performLayout(); } @@ -184,6 +207,11 @@ int main(int argc, char **argv) { net.waitConnections(); + /*auto available = net.findAll<string>("list_streams"); + for (auto &a : available) { + std::cout << " -- " << a << std::endl; + }*/ + try { nanogui::init(); diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp index 1f6201403..050549f18 100644 --- a/applications/reconstruct/src/main.cpp +++ b/applications/reconstruct/src/main.cpp @@ -426,7 +426,10 @@ static void run() { ftl::rgbd::Streamer stream(config, &net); stream.add(virt); - //stream.run(); + // Also proxy all inputs + for (auto &in : inputs) { + stream.add(in.source); + } unsigned char frameCount = 0; bool paused = false; -- GitLab