gpt4 book ai didi

c# - 使用 Kinect v1 for XBOX 将色点映射到深度点

转载 作者:行者123 更新时间:2023-11-30 23:29:13 24 4
gpt4 key购买 nike

我正在从事一个关于使用 kinect 进行生物特征测量的项目。我有一个适用于 Xbox 的 Kinect v1。我可以通过这个kinect获得彩色图像和深度图像。我想映射彩色图像点的深度值。 Kinect sdk 不支持 CoordinateMapper.MapColorPoint2DepthPoint 或空间。所有的坐标变换方法都在这里。 All Mapping Functions List

如何使用 kinect v1 for xbox 将颜色点映射到深度点。谢谢你的回答。

注意:语言:C#,平台:Windows Form

最佳答案

您需要的是 CoordinateMapper.MapDepthFrameToColorFrame method .

Coordinate Mapping Basics-WPF C# Sample显示如何使用此方法。您可以在下面找到代码的一些重要部分:

// Intermediate storage for the depth data received from the sensor
private DepthImagePixel[] depthPixels;
// Intermediate storage for the color data received from the camera
private byte[] colorPixels;
// Intermediate storage for the depth to color mapping
private ColorImagePoint[] colorCoordinates;
// Inverse scaling factor between color and depth
private int colorToDepthDivisor;
// Format we will use for the depth stream
private const DepthImageFormat DepthFormat = DepthImageFormat.Resolution320x240Fps30;
// Format we will use for the color stream
private const ColorImageFormat ColorFormat = ColorImageFormat.RgbResolution640x480Fps30;

//...

// Initialization
this.colorCoordinates = new ColorImagePoint[this.sensor.DepthStream.FramePixelDataLength];
this.depthWidth = this.sensor.DepthStream.FrameWidth;
this.depthHeight = this.sensor.DepthStream.FrameHeight;
int colorWidth = this.sensor.ColorStream.FrameWidth;
int colorHeight = this.sensor.ColorStream.FrameHeight;
this.colorToDepthDivisor = colorWidth / this.depthWidth;
this.sensor.AllFramesReady += this.SensorAllFramesReady;

//...

private void SensorAllFramesReady(object sender, AllFramesReadyEventArgs e)
{
// in the middle of shutting down, so nothing to do
if (null == this.sensor)
{
return;
}

bool depthReceived = false;
bool colorReceived = false;

using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
{
if (null != depthFrame)
{
// Copy the pixel data from the image to a temporary array
depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);

depthReceived = true;
}
}

using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (null != colorFrame)
{
// Copy the pixel data from the image to a temporary array
colorFrame.CopyPixelDataTo(this.colorPixels);

colorReceived = true;
}
}

if (true == depthReceived)
{
this.sensor.CoordinateMapper.MapDepthFrameToColorFrame(
DepthFormat,
this.depthPixels,
ColorFormat,
this.colorCoordinates);

// ...

int depthIndex = x + (y * this.depthWidth);
DepthImagePixel depthPixel = this.depthPixels[depthIndex];

// scale color coordinates to depth resolution
int X = colorImagePoint.X / this.colorToDepthDivisor;
int Y = colorImagePoint.Y / this.colorToDepthDivisor;

// depthPixel is the depth for the (X,Y) pixel in the color frame
}
}

关于c# - 使用 Kinect v1 for XBOX 将色点映射到深度点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35603408/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com