我正在尝试从记录(mkv)中提取深度视频,但是问题在于它是以b16g灰度格式提取的。是否可以使用Azure Kinect Viewer中的颜色提取或获取具有颜色的深度视频?使用的相机是Azure Kinect DK。谢谢,感谢您提供任何反馈意见。
这是我使用的步骤:
ffmpeg -i output.mkv -map 0:1 -vsync 0 depth%03d.png
这将深度轨迹提取为一系列16位PNG。来源:https://docs.microsoft.com/en-us/azure/kinect-dk/record-file-format
然后
ffmpeg -r 30 -i depth%03d.png -c:v libx264 -vf“ fps = 30,format = yuv420p” depth.mp4
根据png图像重新创建深度视频。但是输出的视频是灰度的。来源:How to create a video from images with FFmpeg?
观看者根据最小和最大深度模式对深度进行归一化,以便使用整个16位深度范围。然后,它使用以下代码进行着色。
static inline BgraPixel ColorizeBlueToRed(const DepthPixel &depthPixel,
const DepthPixel &min,
const DepthPixel &max)
{
constexpr uint8_t PixelMax = std::numeric_limits<uint8_t>::max();
// Default to opaque black.
//
BgraPixel result = { 0, 0, 0, PixelMax };
// If the pixel is actual zero and not just below the min value, make it black
//
if (depthPixel == 0)
{
return result;
}
uint16_t clampedValue = depthPixel;
clampedValue = std::min(clampedValue, max);
clampedValue = std::max(clampedValue, min);
// Normalize to [0, 1]
//
float hue = (clampedValue - min) / static_cast<float>(max - min);
// The 'hue' coordinate in HSV is a polar coordinate, so it 'wraps'.
// Purple starts after blue and is close enough to red to be a bit unclear,
// so we want to go from blue to red. Purple starts around .6666667,
// so we want to normalize to [0, .6666667].
//
constexpr float range = 2.f / 3.f;
hue *= range;
// We want blue to be close and red to be far, so we need to reflect the
// hue across the middle of the range.
//
hue = range - hue;
float fRed = 0.f;
float fGreen = 0.f;
float fBlue = 0.f;
ImGui::ColorConvertHSVtoRGB(hue, 1.f, 1.f, fRed, fGreen, fBlue);
result.Red = static_cast<uint8_t>(fRed * PixelMax);
result.Green = static_cast<uint8_t>(fGreen * PixelMax);
result.Blue = static_cast<uint8_t>(fBlue * PixelMax);
return result;
}