2012-04-30 170 views
8

我正在玩新的Kinect SDK v1.0.3.190。 (stackoverflow中的其他相关问题在kinect之前的sdk上) 我从Kinect获得深度和颜色流。由于深度和RGB流通过不同的传感器捕捉,所以两个帧之间会有一个错位,如下所示。Kinect深度和图像帧对齐

只有RGB RGB

只有深度 Depth

深度& RGB RGB & Depth equally blended

我需要对准他们,有一个名为MapDepthToColorImagePoint正是为了这个目的功能。但它似乎并不奏效。这里是一个同样混合(深度和映射颜色)导致下面,其与下面的代码

  Parallel.For(0, this.depthFrameData.Length, i => 
     { 
      int depthVal = this.depthFrameData[i] >> 3; 
      ColorImagePoint point = this.kinectSensor.MapDepthToColorImagePoint(DepthImageFormat.Resolution640x480Fps30, i/640, i % 640, (short)depthVal, ColorImageFormat.RgbResolution640x480Fps30); 
      int baseIndex = Math.Max(0, Math.Min(this.videoBitmapData.Length - 4, (point.Y * 640 + point.X) * 4)); 

      this.mappedBitmapData[baseIndex] = (byte)((this.videoBitmapData[baseIndex])); 
      this.mappedBitmapData[baseIndex + 1] = (byte)((this.videoBitmapData[baseIndex + 1])); 
      this.mappedBitmapData[baseIndex + 2] = (byte)((this.videoBitmapData[baseIndex + 2])); 
     }); 

其中

depthFrameData -> raw depth data (short array) 

videoBitmapData -> raw image data (byte array) 

mappedBitmapData -> expected result data (byte array) 

顺序的参数,分辨率,阵列尺寸是正确的创建(双重检查) 。

代码的结果是: depth and MapDepthToColorImagePoint

失准继续!更糟糕的是,使用MapDepthToColorImagePoint后的结果图像与原始图像完全相同。

,将不胜感激,如果有人可以帮助我找到了我的错误,或者至少给我解释一下什么是(假设我误解了它的功能)MapDepthToColorImagePoint?

回答

1

这是一个非常普遍的问题,涉及到同步的两个图像,因为这两个相机都坐在两个不同的地方数学内在的东西。有点像采用由3D相机产生的两个视频源并尝试同步它们。他们会一直稍微偏离。

整改

两个想法:

  1. 手动为你计算出它的位从深度偏移图像。
  2. 振动器电机添加到Kinect的减少噪音: http://www.youtube.com/watch?v=CSBDY0RuhS4(我找到了一个简单的振动电机是有效的。)

的MapDepthToColorImagePoint是骨骼肌API在使用骨骼点映射到深度点,然后到图像点,以便您可以在RGB图像顶部显示关节。

希望这会有所帮助。

4

,因为两个传感器安装在稍有不同的地方这将始终略微发生。

试试:

看一些对象与你的两只眼睛,然后尝试只用你的左眼,那么只有你的右眼。事情看起来有些不同,因为你的两只眼睛不在完全相同的地方。

但是:有些API代码可以解决很多问题。

我使用Kinect for Windows 1.5,因此API与1.0稍有不同。

short[] depth=new short[320*240]; 
// fill depth with the kinect data 
ColorImagePoint[] colorPoints=new ColorImagePoint[320*240]; 
// convert mappings 
kinect.MapDepthFrameToColorFrame(DepthImageFormat.Resolution320x240Fps30, 
      depth, ColorImageFormat.RgbResolution640x480Fps30, colorPoints); 
// now do something with it 
for(int i=0;i<320*240;i++) 
{ 
    if (we_want_to_display(depth[i])) 
    { 
    draw_on_image_at(colorPoints[i].X,colorPoints[i].Y); 
    } 
} 

这就是基础知识。 如果您查看Kinect Developer Toolkit 1.5中的绿屏示例,它将非常有用。