diff --git a/applications/gui/src/src_window.cpp b/applications/gui/src/src_window.cpp index 008933886c4cfdf0913dec91add26bff88d6a294..f3e84b511868907d6fc65ac14b040bacc537458e 100644 --- a/applications/gui/src/src_window.cpp +++ b/applications/gui/src/src_window.cpp @@ -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; } diff --git a/components/common/cpp/include/ftl/config.h.in b/components/common/cpp/include/ftl/config.h.in index 296da9eec1e60d6848d81d1dec84c1258586664f..67dc859e613e8f1265ef0550669d765138a77a9e 100644 --- a/components/common/cpp/include/ftl/config.h.in +++ b/components/common/cpp/include/ftl/config.h.in @@ -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; diff --git a/components/rgbd-sources/CMakeLists.txt b/components/rgbd-sources/CMakeLists.txt index fe828144030c81c66e754bae65c0bde1fcb20951..d1326ec1647afa6eb91801f29bc4544c333dbb02 100644 --- a/components/rgbd-sources/CMakeLists.txt +++ b/components/rgbd-sources/CMakeLists.txt @@ -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")