fix(record): fall back to millimeter for unknown depth unit

This commit is contained in:
2026-03-12 11:00:25 +08:00
parent 59ff8b79d9
commit a21d4b6769
3 changed files with 81 additions and 26 deletions
+43 -1
View File
@@ -114,6 +114,23 @@ int main(int argc, char **argv) {
return exit_code(TesterExitCode::WriteError);
}
const float depth_unknown_pixels[4] = {
1500.0f,
2500.0f,
std::numeric_limits<float>::quiet_NaN(),
0.0f,
};
cvmmap_streamer::record::RawDepthMapView depth_unknown{};
depth_unknown.timestamp_ns = 13;
depth_unknown.width = 2;
depth_unknown.height = 2;
depth_unknown.source_unit = cvmmap_streamer::ipc::DepthUnit::Unknown;
depth_unknown.pixels = depth_unknown_pixels;
if (auto write = sink->write_depth_map(depth_unknown); !write) {
spdlog::error("failed to write unknown-unit depth map: {}", write.error());
return exit_code(TesterExitCode::WriteError);
}
sink->close();
mcap::McapReader reader{};
@@ -173,7 +190,7 @@ int main(int argc, char **argv) {
reader.close();
if (video_messages != 1 || depth_messages.size() != 2) {
if (video_messages != 1 || depth_messages.size() != 3) {
spdlog::error(
"unexpected message counts: video={} depth={}",
video_messages,
@@ -231,6 +248,31 @@ int main(int argc, char **argv) {
return exit_code(TesterExitCode::VerificationError);
}
const auto &unknown_message = depth_messages[2];
if (unknown_message.source_unit() != cvmmap_streamer::DepthMap::DEPTH_UNIT_MILLIMETER ||
unknown_message.storage_unit() != cvmmap_streamer::DepthMap::STORAGE_UNIT_MILLIMETER ||
unknown_message.encoding() != cvmmap_streamer::DepthMap::RVL_U16_LOSSLESS) {
spdlog::error("unknown-unit fallback metadata verification failed");
return exit_code(TesterExitCode::VerificationError);
}
const auto unknown_info = rvl::inspect_image(std::span<const std::uint8_t>(
reinterpret_cast<const std::uint8_t *>(unknown_message.data().data()),
unknown_message.data().size()));
const auto unknown_decoded = rvl::decompress_image(std::span<const std::uint8_t>(
reinterpret_cast<const std::uint8_t *>(unknown_message.data().data()),
unknown_message.data().size()));
if (unknown_info.format != rvl::ImageFormat::UInt16Lossless ||
unknown_info.rows != 2 ||
unknown_info.cols != 2 ||
unknown_decoded.pixels.size() != 4 ||
unknown_decoded.pixels[0] != 1500 ||
unknown_decoded.pixels[1] != 2500 ||
unknown_decoded.pixels[2] != 0 ||
unknown_decoded.pixels[3] != 0) {
spdlog::error("unknown-unit fallback RVL round-trip verification failed");
return exit_code(TesterExitCode::VerificationError);
}
spdlog::info(
"validated same-file MCAP video+depth recording at '{}'",
output_path.string());