gtsam_points
Loading...
Searching...
No Matches
screen_capture.hpp
Go to the documentation of this file.
1#ifndef GUIK_SCREEN_CAPTURE
2#define GUIK_SCREEN_CAPTURE
3
4#include <deque>
5#include <memory>
6#include <atomic>
7#include <thread>
8#include <iostream>
9#include <Eigen/Core>
11
12namespace glk {
13class Texture;
14class PixelBuffer;
15} // namespace glk
16
17namespace guik {
18
24public:
25 using Pixels = std::vector<unsigned char>;
26 using PixelsPtr = std::shared_ptr<Pixels>;
27 using ImageSaveData = std::pair<std::string, PixelsPtr>;
28
37 const Eigen::Vector2i& image_size,
38 int num_encode_threads,
39 int num_pixel_buffers = 2,
40 std::shared_ptr<guik::ConcurrentQueue<ImageSaveData>> queue = std::make_shared<guik::StdConcurrentQueue<ImageSaveData>>());
42
46 size_t queue_size() const;
47
52 void capture(const std::string& dst_filename);
53
58 void capture(const std::string& dst_filename, const glk::Texture& texture);
59
60private:
61 void encode_task();
62
63private:
64 const Eigen::Vector2i image_size;
65
66 size_t capture_count;
67 std::vector<std::string> dst_filenames;
68 std::vector<std::shared_ptr<glk::PixelBuffer>> pixel_buffers;
69
70 std::atomic_bool kill_switch;
71 std::vector<std::thread> encode_threads;
72
73 std::shared_ptr<guik::ConcurrentQueue<ImageSaveData>> input_queue;
74};
75
76} // namespace guik
77
78#endif
Definition texture.hpp:10
Definition concurrent_queue.hpp:10
Screen capture utility to asynchronously fetch rendering results and save them as images.
Definition screen_capture.hpp:23
ScreenCapture(const Eigen::Vector2i &image_size, int num_encode_threads, int num_pixel_buffers=2, std::shared_ptr< guik::ConcurrentQueue< ImageSaveData > > queue=std::make_shared< guik::StdConcurrentQueue< ImageSaveData > >())
Constructor.
size_t queue_size() const
Image encoding queue size.
std::pair< std::string, PixelsPtr > ImageSaveData
Definition screen_capture.hpp:27
void capture(const std::string &dst_filename)
Capture the viewer main canvas and save it as a image file.
std::shared_ptr< Pixels > PixelsPtr
Definition screen_capture.hpp:26
void capture(const std::string &dst_filename, const glk::Texture &texture)
Capture texture contents and save it as a image file.
std::vector< unsigned char > Pixels
Definition screen_capture.hpp:25
Definition concurrent_queue.hpp:20
Definition async_buffer_copy.hpp:6
Definition drawable_container.hpp:9