32#include <opencv2/opencv.hpp>
45 const std::filesystem::path& filePath,
46 const std::string& file_name,
47 unsigned int png_compression) :
62 const std::filesystem::path& path)
64 std::filesystem::path snapshotPath(path);
68 <<
"Cannot take snapshot, path '" + path.parent_path().string() +
"' does ot exist";
70 if (snapshotPath.extension() !=
".png")
72 snapshotPath +=
".png";
75 const int snapshot_compression = 9;
76 std::vector<int> params{cv::IMWRITE_PNG_COMPRESSION,
78 cv::IMWRITE_PNG_STRATEGY,
79 cv::IMWRITE_PNG_STRATEGY_RLE};
80 cv::imwrite(snapshotPath.string(), image, params);
85 const std::filesystem::path& path)
102 const std::chrono::microseconds
timestamp)
105 const std::filesystem::path path =
deriveFramePath(sequence_number, frame_name);
106 std::vector<int> params{cv::IMWRITE_PNG_COMPRESSION,
108 cv::IMWRITE_PNG_STRATEGY,
109 cv::IMWRITE_PNG_STRATEGY_RLE};
110 cv::imwrite(path.string(), frame, params);
virtual std::tuple< unsigned int, std::string > writeMetadataFrame(const CByteImage &frame, std::chrono::microseconds timestamp)
virtual void writeMetadataLine(const std::string &var_name, std::string_view var_type, std::string_view var_value)
void startRecording() override
Starts the recording manually if constructed empty.
AbstractSequencedRecordingStrategy()
Default constructor to manually start the recording.
std::filesystem::path deriveFramePath(const unsigned int sequence_number, const std::string &frame_name)
Returns the next sequenced full path and increments the sequence number.
unsigned int m_png_compression
void startRecording() override
Starts the recording manually if constructed empty.
static void recordSnapshot(const cv::Mat &image, const std::filesystem::path &path)
void recordFrame(const cv::Mat &frame, std::chrono::microseconds timestamp) override
Adds the given frame to the recording.
~PNGRecordingStrategy() override
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_CHECK_LESS_EQUAL(lhs, rhs)
This macro evaluates whether lhs is less or equal (<=) rhs and if it turns out to be false it will th...
#define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs)
This macro evaluates whether lhs is greater or equal (>=) rhs and if it turns out to be false it will...
void convert(const CByteImage &in, cv::Mat &out)
Converts an IVT CByteImage to OpenCV's BGR Mat.