public_api.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package visionx::imrec
17  * @author Christian R. G. Dreher <c.dreher@kit.edu>
18  * @date 2018
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 
24 #pragma once
25 
26 
27 // STD/STL
28 #include <filesystem>
29 #include <map>
30 
31 // ArmarX
34 
35 
36 class CByteImage;
37 
38 
39 namespace cv
40 {
41  class Mat;
42 }
43 
44 
45 namespace visionx::imrec
46 {
47 
48 
49  /**
50  * @brief Supported recording Formats.
51  *
52  * @note If you add new formats, also add them to the registry (declared in an anonymous
53  * namespace) in public_api.cpp.
54  */
55  enum class Format
56  {
65  };
66 
67 
68  enum class Framerate
69  {
70  static_fps,
72  };
73 
74 
75  enum class Compression
76  {
77  lossy,
78  lossless
79  };
80 
81 
83  {
84  /**
85  * @brief Identifier to use for long-term storage purposes etc.
86  */
87  std::string id;
88 
89  /**
90  * @brief Human readable identifier for UI's or outputs. May change, so do not use as an
91  * identifier for long-term storage.
92  */
93  std::string hr_name;
94 
95  /**
96  * @brief Framerate handling
97  */
99 
100  /**
101  * @brief Compression handling
102  */
104  };
105 
106 
107  const std::string& format2str(const Format format);
108 
109 
110  const std::string& format2hrstr(const Format format);
111 
112 
113  Format str2format(const std::string& format_str);
114 
115 
116  std::vector<Format> getFormats();
117 
118 
119  std::map<Format, RegistryEntry> getFormatsMap();
120 
121 
122  bool isFormatLossless(Format format);
123 
124 
125  bool isFormatDynamicFramerate(Format format);
126 
127 
128  /**
129  * @brief Instantiates and returns a new playback strategy which is capable of replaying the file or collection at path
130  * @param path Path to the recording file or collection (folder, glob, ...)
131  * @return Concrete playback strategy capable of replaying the recording at path
132  */
133  visionx::imrec::Playback newPlayback(const std::filesystem::path& path);
134 
135 
136  visionx::imrec::Recording newRecording(const std::filesystem::path& path, const std::string& name, const Format format, double fps);
137 
138 
139  /**
140  * @brief Creates a new recording given the file extension and additional parameters
141  * @param filePath Path to where the recording file should be written to
142  * @param fps Amount of frames being recorded per second
143  * @return Recording object
144  */
145  visionx::imrec::Recording newRecording(const std::filesystem::path& filePath, double fps);
146 
147 
148  /**
149  * @brief Takes a snapshot using the default recording method for snapshots
150  * @param filePath Path to where the recording file should be written to
151  * @param image The image to be saved
152  */
153  void takeSnapshot(const CByteImage& image, const std::filesystem::path& filePath);
154 
155 
156  /**
157  * @brief Takes a snapshot using the default recording method for snapshots
158  * @param filePath Path to where the recording file should be written to
159  * @param image The image to be saved
160  */
161  void takeSnapshot(const cv::Mat& image, const std::filesystem::path& filePath);
162 
163 }
visionx::imrec::Format::bmp_img_seq
@ bmp_img_seq
visionx::imrec::getFormatsMap
std::map< Format, RegistryEntry > getFormatsMap()
Definition: public_api.cpp:184
visionx::imrec::Format
Format
Supported recording Formats.
Definition: public_api.h:55
visionx::imrec::RegistryEntry::compression
Compression compression
Compression handling.
Definition: public_api.h:103
visionx::imrec::Framerate::dynamic_fps
@ dynamic_fps
AbstractPlaybackStrategy.h
visionx::imrec::getFormats
std::vector< Format > getFormats()
Definition: public_api.cpp:172
visionx::imrec::Format::avi_default
@ avi_default
visionx::imrec::isFormatLossless
bool isFormatLossless(Format format)
Definition: public_api.cpp:191
visionx::imrec::Format::png_fast_mt_img_seq
@ png_fast_mt_img_seq
visionx::imrec::Framerate::static_fps
@ static_fps
visionx::imrec::RegistryEntry
Definition: public_api.h:82
visionx::imrec::RegistryEntry::hr_name
std::string hr_name
Human readable identifier for UI's or outputs.
Definition: public_api.h:93
visionx::imrec::RegistryEntry::framerate
Framerate framerate
Framerate handling.
Definition: public_api.h:98
visionx::imrec::Compression
Compression
Definition: public_api.h:75
visionx::imrec::Playback
std::shared_ptr< visionx::imrec::AbstractPlaybackStrategy > Playback
Convenience alias for an instance of any playback strategy.
Definition: AbstractPlaybackStrategy.h:48
visionx::imrec::format2str
const std::string & format2str(const Format format)
Definition: public_api.cpp:145
visionx::imrec::Format::png_img_seq
@ png_img_seq
AbstractRecordingStrategy.h
visionx::imrec::Compression::lossless
@ lossless
visionx::imrec::takeSnapshot
void takeSnapshot(const CByteImage &image, const std::filesystem::path &filePath)
Takes a snapshot using the default recording method for snapshots.
Definition: public_api.cpp:307
visionx::imrec::Framerate
Framerate
Definition: public_api.h:68
visionx::imrec::format2hrstr
const std::string & format2hrstr(const Format format)
Definition: public_api.cpp:152
visionx::imrec::Format::png_fast_img_seq
@ png_fast_img_seq
visionx::imrec::newRecording
visionx::imrec::Recording newRecording(const std::filesystem::path &path, const std::string &name, const Format format, double fps)
Definition: public_api.cpp:237
visionx::imrec::Recording
std::shared_ptr< AbstractRecordingStrategy > Recording
Convenience alias for any recording strategy.
Definition: AbstractRecordingStrategy.h:181
visionx::imrec::str2format
Format str2format(const std::string &format_str)
Definition: public_api.cpp:159
visionx::imrec::newPlayback
visionx::imrec::Playback newPlayback(const std::filesystem::path &path)
Instantiates and returns a new playback strategy which is capable of replaying the file or collection...
Definition: public_api.cpp:205
visionx::imrec::Compression::lossy
@ lossy
visionx::imrec::Format::jpg_img_seq
@ jpg_img_seq
visionx::imrec::RegistryEntry::id
std::string id
Identifier to use for long-term storage purposes etc.
Definition: public_api.h:87
cv
Definition: helper.h:35
visionx::imrec
Definition: json_conversions.h:35
visionx::imrec::Format::png_mt_img_seq
@ png_mt_img_seq
visionx::imrec::Format::mp4_default
@ mp4_default
visionx::imrec::isFormatDynamicFramerate
bool isFormatDynamicFramerate(Format format)
Definition: public_api.cpp:198