Skip to content
Snippets Groups Projects

Feature/219/gui record options

Merged Iiro Rastas requested to merge feature/219/gui-record-options into master
3 files
+ 34
0
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -137,6 +137,7 @@ ftl::gui::Camera::Camera(ftl::gui::Screen *screen, ftl::rgbd::Source *src) : scr
sdepth_ = false;
ftime_ = (float)glfwGetTime();
pause_ = false;
videowriter_ = std::nullopt;
channel_ = Channel::Left;
@@ -488,6 +489,12 @@ const GLTexture &ftl::gui::Camera::captureFrame() {
//imageSize = Vector2f(rgb.cols,rgb.rows);
texture1_.update(im1_);
}
if (videowriter_) {
cv::Mat image;
cv::flip(im1_, image, 0);
videowriter_.value().write(image);
}
}
return texture1_;
@@ -503,6 +510,21 @@ void ftl::gui::Camera::snapshot() {
cv::imwrite(std::string(timestamp) + ".png", image);
}
void ftl::gui::Camera::toggleVideoRecording() {
if (videowriter_) {
videowriter_.value().release();
videowriter_ = std::nullopt;
} else {
char timestamp[18];
std::time_t t = std::time(NULL);
std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t));
videowriter_ = std::optional<cv::VideoWriter>(cv::VideoWriter(std::string(timestamp) + ".avi",
cv::VideoWriter::fourcc('M','J','P','G'),
screen_->root()->value("fps", 20),
cv::Size(width(), height())));
}
}
nlohmann::json ftl::gui::Camera::getMetaData() {
return nlohmann::json();
}
Loading