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
36class CByteImage;
37
38namespace cv
39{
40 class Mat;
41}
42
43namespace visionx::imrec
44{
45
46
47 /**
48 * @brief Supported recording Formats.
49 *
50 * @note If you add new formats, also add them to the registry (declared in an anonymous
51 * namespace) in public_api.cpp.
52 */
64
65
66 enum class Framerate
67 {
70 };
71
72
73 enum class Compression
74 {
77 };
78
80 {
81 /**
82 * @brief Identifier to use for long-term storage purposes etc.
83 */
84 std::string id;
85
86 /**
87 * @brief Human readable identifier for UI's or outputs. May change, so do not use as an
88 * identifier for long-term storage.
89 */
90 std::string hr_name;
91
92 /**
93 * @brief Framerate handling
94 */
96
97 /**
98 * @brief Compression handling
99 */
101 };
102
103 const std::string& format2str(const Format format);
104
105
106 const std::string& format2hrstr(const Format format);
107
108
109 Format str2format(const std::string& format_str);
110
111
112 std::vector<Format> getFormats();
113
114
115 std::map<Format, RegistryEntry> getFormatsMap();
116
117
118 bool isFormatLossless(Format format);
119
120
121 bool isFormatDynamicFramerate(Format format);
122
123
124 /**
125 * @brief Instantiates and returns a new playback strategy which is capable of replaying the file or collection at path
126 * @param path Path to the recording file or collection (folder, glob, ...)
127 * @return Concrete playback strategy capable of replaying the recording at path
128 */
129 visionx::imrec::Playback newPlayback(const std::filesystem::path& path);
130
131
132 visionx::imrec::Recording newRecording(const std::filesystem::path& path,
133 const std::string& name,
134 const Format format,
135 double fps);
136
137
138 /**
139 * @brief Creates a new recording given the file extension and additional parameters
140 * @param filePath Path to where the recording file should be written to
141 * @param fps Amount of frames being recorded per second
142 * @return Recording object
143 */
144 visionx::imrec::Recording newRecording(const std::filesystem::path& filePath, double fps);
145
146
147 /**
148 * @brief Takes a snapshot using the default recording method for snapshots
149 * @param filePath Path to where the recording file should be written to
150 * @param image The image to be saved
151 */
152 void takeSnapshot(const CByteImage& image, const std::filesystem::path& filePath);
153
154
155 /**
156 * @brief Takes a snapshot using the default recording method for snapshots
157 * @param filePath Path to where the recording file should be written to
158 * @param image The image to be saved
159 */
160 void takeSnapshot(const cv::Mat& image, const std::filesystem::path& filePath);
161
162} // namespace visionx::imrec
Definition helper.h:35
bool isFormatDynamicFramerate(Format format)
const std::string & format2str(const Format format)
std::vector< Format > getFormats()
visionx::imrec::Recording newRecording(const std::filesystem::path &path, const std::string &name, const Format format, double fps)
std::map< Format, RegistryEntry > getFormatsMap()
void takeSnapshot(const CByteImage &image, const std::filesystem::path &filePath)
Takes a snapshot using the default recording method for snapshots.
Format str2format(const std::string &format_str)
const std::string & format2hrstr(const Format format)
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...
Format
Supported recording Formats.
Definition public_api.h:54
std::shared_ptr< visionx::imrec::AbstractPlaybackStrategy > Playback
Convenience alias for an instance of any playback strategy.
std::shared_ptr< AbstractRecordingStrategy > Recording
Convenience alias for any recording strategy.
bool isFormatLossless(Format format)
Framerate framerate
Framerate handling.
Definition public_api.h:95
Compression compression
Compression handling.
Definition public_api.h:100
std::string hr_name
Human readable identifier for UI's or outputs.
Definition public_api.h:90
std::string id
Identifier to use for long-term storage purposes etc.
Definition public_api.h:84