2016-02-24 2 views
2

Я работаю над проектом, касающимся биометрических измерений с помощью kinect. У меня есть Kinect v1 для Xbox. Я могу получить цветное изображение и изображение глубины через этот kinect. Я хочу отображать значение глубины цвета точки изображения. Kinect sdk не поддерживает CoordinateMapper.MapColorPoint2DepthPoint или пробел. Здесь все методы преобразования координат. All Mapping Functions ListОтображение цветовой точки до точки глубины с помощью Kinect v1 для XBOX

Как я могу сопоставить точку цвета с точкой кина с kinect v1 для xbox. Спасибо за ответы.

Примечание: Язык: C#, Платформа: Форма для Windows

ответ

1

Что вам нужно, это 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 
    } 
} 
1

Спасибо Vito ваш быстрый ответ. Я решил, что Kinect sdk предоставит мне от рамки глубины до цветной рамки. Я нахожу значение глубины точки изображения (x, y) от мануальной обратной транзакции карты глубины цвета.

Эта функция возвращает значение глубины для определенной точки цветного изображения.

public int GetDepthFromColorImagePoint(KinectSensor sensor, DepthImageFormat depthImageFormat, ColorImageFormat colorImageFormat, DepthImagePixel[] depthPixels, int depthWidth, int depthHeight, int colorImageX, int colorImageY) 
{ 
    ColorImagePoint[] color_points = new ColorImagePoint[depthHeight * depthWidth]; 

    sensor.CoordinateMapper.MapDepthFrameToColorFrame(depthImageFormat, depthPixels, colorImageFormat, color_points); 

    int depthIndex = color_points.ToList().FindIndex(p => p.X == colorImageX && p.Y == colorImageY); 
     if (depthIndex < 0) 
      return -1; 
     short depthValue = depthPixels[depthIndex].Depth; 
     return depthValue; 
} 

если вы видите результат этой функции просмотра этой gif

Смежные вопросы