Skip to content
Snippets Groups Projects
Commit 3ce5684d authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

fix snapshot build; add snapshot button to GUI

parent bb6cc858
No related branches found
No related tags found
No related merge requests found
Pipeline #11259 passed
......@@ -8,6 +8,10 @@
#include <nanogui/screen.h>
#include <nanogui/layout.h>
#ifdef HAVE_LIBARCHIVE
#include "ftl/snapshot.hpp"
#endif
using ftl::gui::SourceWindow;
using ftl::rgbd::RGBDSource;
using std::string;
......@@ -175,11 +179,36 @@ SourceWindow::SourceWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl)
image_->setDepth(state);
});
#ifdef HAVE_LIBARCHIVE
auto snapshot = new Button(tools, "Snapshot");
snapshot->setCallback([this] {
try {
char timestamp[18];
std::time_t t=std::time(NULL);
std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t));
auto writer = ftl::rgbd::SnapshotWriter(std::string(timestamp) + ".tar.gz");
cv::Mat rgb, depth;
this->src_->getRGBD(rgb, depth);
if (!writer.addCameraRGBD(
"0", // TODO
rgb,
depth,
this->src_->getPose(),
this->src_->getParameters()
)) {
LOG(ERROR) << "Snapshot failed";
}
}
catch(std::runtime_error) {
LOG(ERROR) << "Snapshot failed (file error)";
}
});
#endif
auto imageView = new VirtualCameraView(this);
//cam.view = imageView;
imageView->setGridThreshold(20);
imageView->setSource(src_);
auto imageView = new VirtualCameraView(this);
//cam.view = imageView;
imageView->setGridThreshold(20);
imageView->setSource(src_);
image_ = imageView;
}
......
......@@ -20,6 +20,7 @@
#cmakedefine HAVE_RENDER
#cmakedefine HAVE_LIBSGM
#cmakedefine HAVE_NANOGUI
#cmakedefine HAVE_LIBARCHIVE
extern const char *FTL_VERSION_LONG;
extern const char *FTL_VERSION;
......
......@@ -12,12 +12,12 @@ set(RGBDSRC
src/algorithms/opencv_bm.cpp
)
if (LIBARCHIVE_FOUND)
if (LibArchive_FOUND)
list(APPEND RGBDSRC
"src/snapshot.cpp"
"src/snapshot_source.cpp"
src/snapshot.cpp
src/snapshot_source.cpp
)
endif (LIBARCHIVE_FOUND)
endif (LibArchive_FOUND)
if (LIBSGM_FOUND)
list(APPEND RGBDSRC "src/algorithms/fixstars_sgm.cpp")
......
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