Skip to content
Snippets Groups Projects
Commit d3e66259 authored by Iiro Rastas's avatar Iiro Rastas
Browse files

Add snapshot feature and fix settings window

The GUI now has a snapshot feature. The record button opens a popup
window, which contains the different recording options.

The cog icon now opens a scrollable list of all of the registered
configurations, both local and remote. This window is created
dynamically each time the cog icon is clicked, so it now includes all of the
configurations that were available as the window was created.
parent 9b369c0b
No related branches found
No related tags found
1 merge request!179Feature/219/gui record options
Pipeline #16320 passed
...@@ -493,6 +493,16 @@ const GLTexture &ftl::gui::Camera::captureFrame() { ...@@ -493,6 +493,16 @@ const GLTexture &ftl::gui::Camera::captureFrame() {
return texture1_; return texture1_;
} }
void ftl::gui::Camera::snapshot() {
UNIQUE_LOCK(mutex_, lk);
char timestamp[18];
std::time_t t = std::time(NULL);
std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t));
cv::Mat image;
cv::flip(im1_, image, 0);
cv::imwrite(std::string(timestamp) + ".png", image);
}
nlohmann::json ftl::gui::Camera::getMetaData() { nlohmann::json ftl::gui::Camera::getMetaData() {
return nlohmann::json(); return nlohmann::json();
} }
...@@ -51,6 +51,8 @@ class Camera { ...@@ -51,6 +51,8 @@ class Camera {
bool thumbnail(cv::Mat &thumb); bool thumbnail(cv::Mat &thumb);
void snapshot();
nlohmann::json getMetaData(); nlohmann::json getMetaData();
StatisticsImage *stats_ = nullptr; StatisticsImage *stats_ = nullptr;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <nanogui/button.h> #include <nanogui/button.h>
#include <nanogui/entypo.h> #include <nanogui/entypo.h>
#include <nanogui/formhelper.h> #include <nanogui/formhelper.h>
#include <nanogui/vscrollpanel.h>
#include <vector> #include <vector>
#include <string> #include <string>
...@@ -27,8 +28,13 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl) ...@@ -27,8 +28,13 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl)
new Label(this, "Select Configurable","sans-bold"); new Label(this, "Select Configurable","sans-bold");
auto vscroll = new VScrollPanel(this);
vscroll->setFixedHeight(300);
Widget *buttons = new Widget(vscroll);
buttons->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill));
for (auto c : configurables_) { for (auto c : configurables_) {
auto itembutton = new Button(this, c); auto itembutton = new Button(buttons, c);
itembutton->setCallback([this,c]() { itembutton->setCallback([this,c]() {
LOG(INFO) << "Change configurable: " << c; LOG(INFO) << "Change configurable: " << c;
_buildForm(c); _buildForm(c);
......
...@@ -34,9 +34,22 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""), ...@@ -34,9 +34,22 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""),
if (cam) cam->showPoseWindow(); if (cam) cam->showPoseWindow();
}); });
button = new Button(this, "", ENTYPO_ICON_CONTROLLER_RECORD); auto recordbutton = new PopupButton(this, "", ENTYPO_ICON_CONTROLLER_RECORD);
button->setFlags(Button::ToggleButton); recordbutton->setTooltip("Record");
button->setChangeCallback([this,button](bool state) { recordbutton->setSide(Popup::Side::Right);
recordbutton->setChevronIcon(0);
auto recordpopup = recordbutton->popup();
recordpopup->setLayout(new GroupLayout());
recordpopup->setTheme(screen->toolbuttheme);
recordpopup->setAnchorHeight(150);
auto itembutton = new Button(recordpopup, "Snapshot");
itembutton->setCallback([this](){
screen_->activeCamera()->snapshot();
});
itembutton = new Button(recordpopup, "2D video recording");
itembutton = new Button(recordpopup, "Depth video recording");
itembutton->setFlags(Button::ToggleButton);
itembutton->setChangeCallback([this,recordbutton](bool state) {
auto tag = screen_->activeCamera()->source()->get<std::string>("uri"); auto tag = screen_->activeCamera()->source()->get<std::string>("uri");
if (tag) { if (tag) {
auto tagvalue = tag.value(); auto tagvalue = tag.value();
...@@ -45,14 +58,16 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""), ...@@ -45,14 +58,16 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""),
ftl::Configurable *configurable = configurables[0]; ftl::Configurable *configurable = configurables[0];
if (state){ if (state){
configurable->set("record", true); configurable->set("record", true);
button->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f)); recordbutton->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
} else { } else {
button->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f)); recordbutton->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f));
configurable->set("record", false); configurable->set("record", false);
} }
} }
} }
}); });
itembutton = new Button(recordpopup, "3D scene recording");
itembutton = new Button(recordpopup, "Detailed recording options");
button = new Button(this, "", ENTYPO_ICON_CONTROLLER_STOP); button = new Button(this, "", ENTYPO_ICON_CONTROLLER_STOP);
button->setCallback([this]() { button->setCallback([this]() {
......
...@@ -213,18 +213,18 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl ...@@ -213,18 +213,18 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl
popup->setVisible(false); popup->setVisible(false);
}); });
popbutton = new PopupButton(innertool, "", ENTYPO_ICON_COG); itembutton = new Button(innertool, "", ENTYPO_ICON_COG);
popbutton->setIconExtraScale(1.5f); itembutton->setIconExtraScale(1.5f);
popbutton->setTheme(toolbuttheme); itembutton->setTheme(toolbuttheme);
popbutton->setTooltip("Settings"); itembutton->setTooltip("Settings");
popbutton->setFixedSize(Vector2i(40,40)); itembutton->setFixedSize(Vector2i(40,40));
popbutton->setSide(Popup::Side::Right);
popbutton->setChevronIcon(0); itembutton->setCallback([this]() {
// popbutton->setPosition(Vector2i(5,height()-50)); auto config_window = new ConfigWindow(this, ctrl_);
popup = popbutton->popup(); config_window->setTheme(windowtheme);
popup->setLayout(new GroupLayout()); });
popup->setTheme(toolbuttheme);
/*
//net_->onConnect([this,popup](ftl::net::Peer *p) { //net_->onConnect([this,popup](ftl::net::Peer *p) {
{ {
LOG(INFO) << "NET CONNECT"; LOG(INFO) << "NET CONNECT";
...@@ -247,6 +247,7 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl ...@@ -247,6 +247,7 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl
auto config_window = new ConfigWindow(this, ctrl_); auto config_window = new ConfigWindow(this, ctrl_);
config_window->setTheme(windowtheme); config_window->setTheme(windowtheme);
}); });
*/
//configwindow_ = new ConfigWindow(parent, ctrl_); //configwindow_ = new ConfigWindow(parent, ctrl_);
cwindow_ = new ftl::gui::ControlWindow(this, controller); cwindow_ = new ftl::gui::ControlWindow(this, controller);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment