25 #define METADATA_VERSION "2.0"
35 #include <opencv2/opencv.hpp>
38 #include <Image/ByteImage.h>
54 m_file_path{file_path},
83 std::filesystem::create_directories(m_file_path.parent_path());
98 recordFrame(cv_frame, time);
109 CByteImage ivt_frame;
111 recordFrame(ivt_frame, time);
118 writeMetadataLine(
"frame_count",
"unsigned int",
std::to_string(m_sequence_number));
120 if (m_metadata_file.is_open())
122 m_metadata_file.close();
127 std::filesystem::path
134 std::filesystem::path
137 return m_file_path.parent_path();
141 std::filesystem::path
144 return m_file_path.stem();
148 std::filesystem::path
151 return m_file_path.extension();
155 std::filesystem::path
158 std::filesystem::path path = getPath();
159 std::filesystem::path
filename = getStem().string() +
"_metadata.csv";
160 return std::filesystem::canonical(path) /
filename;
164 std::tuple<unsigned int, std::string>
167 writeMetadataLine(
"frame_height",
"unsigned int",
std::to_string(
static_cast<unsigned int>(frame.height)));
168 writeMetadataLine(
"frame_width",
"unsigned int",
std::to_string(
static_cast<unsigned int>(frame.width)));
169 return writeMetadataFrameFileInfo(timestamp);
173 std::tuple<unsigned int, std::string>
176 writeMetadataLine(
"frame_height",
"unsigned int",
std::to_string(
static_cast<unsigned int>(frame.size().height)));
177 writeMetadataLine(
"frame_width",
"unsigned int",
std::to_string(
static_cast<unsigned int>(frame.size().width)));
178 return writeMetadataFrameFileInfo(timestamp);
182 std::tuple<unsigned int, std::string>
183 visionx::imrec::AbstractRecordingStrategy::writeMetadataFrameFileInfo(
const std::chrono::microseconds timestamp)
185 const unsigned int sequence_number = m_sequence_number++;
188 if (m_reference_time.count() == 0)
190 m_reference_time = timestamp;
191 writeMetadataDatetime(
"frame_0_system_reference_time", timestamp);
195 const std::chrono::microseconds normalized_time = timestamp - m_reference_time;
199 writeMetadataLine(
"frame_" +
std::to_string(sequence_number),
"string", normalized_time_str);
201 return {sequence_number, normalized_time_str};
208 writeMetadataLine(var_name +
"_us",
"long",
std::to_string(timestamp.count()));
216 if (not m_metadata_file.is_open())
218 m_metadata_file.open(getMetadataPath());
219 writeMetadataLine(
"name",
"type",
"value");
224 if (m_written_metadata_variables.insert(var_name).second ==
false)
229 m_metadata_file << var_name <<
"," << var_type <<
"," << var_value <<
"\n";
230 m_metadata_file.flush();