32 #include <opencv2/opencv.hpp>
45 const std::filesystem::path& filePath,
46 const std::string& file_name,
47 unsigned int png_compression) :
49 m_png_compression{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)
90 recordSnapshot(cv_image, path);
97 writeMetadataLine(
"png_compression",
"unsigned int",
std::to_string(m_png_compression));
102 const std::chrono::microseconds
timestamp)
104 const auto& [sequence_number, frame_name] = writeMetadataFrame(frame,
timestamp);
105 const std::filesystem::path path = deriveFramePath(sequence_number, frame_name);
106 std::vector<int> params{cv::IMWRITE_PNG_COMPRESSION,
107 static_cast<int>(m_png_compression),
108 cv::IMWRITE_PNG_STRATEGY,
109 cv::IMWRITE_PNG_STRATEGY_RLE};
110 cv::imwrite(path.string(), frame, params);