【问题标题】:Converting Kinect Methods from Beta 2, to Version 1将 Kinect 方法从 Beta 2 转换为版本 1
【发布时间】:2012-04-28 21:13:59
【问题描述】:

所以我将getDisplayPosition 从 Kinect SDK 的测试版转换为完整版。这是我现在拥有的

原版

 private Point getDisplayPosition(Joint joint)
    {
        float depthX, depthY;
        nui.SkeletonEngine.SkeletonToDepthImage(joint.Position, out depthX, out depthY);
        depthX = Math.Max(0, Math.Min(depthX * 320, 320));  //convert to 320, 240 space
        depthY = Math.Max(0, Math.Min(depthY * 240, 240));  //convert to 320, 240 space
        int colorX, colorY;
        ImageViewArea iv = new ImageViewArea();
        // only ImageResolution.Resolution640x480 is supported at this point
        nui.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(ImageResolution.Resolution640x480, iv, (int)depthX, (int)depthY, (short)0, out colorX, out colorY);


        // map back to skeleton.Width & skeleton.Height
        return new Point((int)(skeleton.Width * colorX / 640.0), (int)(skeleton.Height * colorY / 480));
    }


我的版本

private Point getDisplayPosition(Joint joint)
    {
        float depthX, depthY;
        KinectSensor sensor = kinectSensorChooser1.Kinect;
        DepthImageFormat depth = DepthImageFormat.Resolution320x240Fps30;
        depthX = 320;
        depthY = 240;
        sensor.MapSkeletonPointToDepth(joint.Position, depth);
        depthX = Math.Max(0, Math.Min(depthX * 320, 320));
        depthY = Math.Max(0, Math.Min(depthY * 240, 240));
        int colorX, colorY;
        colorX = 320;
        colorY = 240;

        return new Point((int)(skeleton.Width * colorX / 640.0), (int)(skeleton.Height * colorY / 480));
    }

基本上我想知道我的版本是否会和原版做同样的事情,如果不是,如何修复它。

【问题讨论】:

标签: c# kinect


【解决方案1】:

这就是我所做的,它对我有用(这与你的非常相似) - 我希望它有所帮助:

我的版本

private Point getDisplayPosition(DepthImageFrame depthFrame, Joint joint)
{ 
    float depthX, depthY;        
    DepthImagePoint depthPoint = kineticSensor.MapSkeletonPointToDepth(joint.Position, depthImageFormat);

    depthX = depthPoint.X;
    depthY = depthPoint.Y;

    depthX = Math.Max(0, Math.Min(depthX * 320, 320));
    depthY = Math.Max(0, Math.Min(depthY * 240, 240));

    int colorX, colorY;
    ColorImagePoint colorPoint = depthFrame.MapToColorImagePoint(depthPoint.X, depthPoint.Y, sensor.ColorStream.Format);
    colorX = colorPoint.X;
    colorY = colorPoint.Y;

    return new Point((int)(skeleton.Width * colorX / 640.0), (int)(skeleton.Height * colorY / 480));
}

【讨论】:

  • 抱歉不能通过电话提供赏金:P
  • 哦,但我不是也需要DepthImageFrame 吗?那会有什么影响吗?还有depthImageFormatsensor是什么?
  • depthImageFormat(DepthImageFormat 实例)和 Sensor(KineticSensor 实例)是我代码中的几个变量。我在窗口加载时分配这些。我使用 depthImageFrame 来利用内置的 MapToColorImagePoint 方法。我使用 depthImageFormat 因为我的想法是这是 KineticSensor 的初始化值,所以我想在这方面使用相同的设置。在我的代码中,“传感器”只是在窗口加载时实例化的 KinectSensor 的一个实例。同样,depthImageFormat 也是我在启动传感器后分配的变量。
  • 仅供参考,当您说sensor.ColorStreamFormat 时,我发现它确实是sensor.ColorStream.Format,因为'sensor 没有ColorStreamFormat 的定义'
  • 哈哈,这不是好事,那天我和 KinectSensor 的成员交流了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-08
  • 2015-09-02
  • 1970-01-01
  • 1970-01-01
  • 2021-10-03
  • 1970-01-01
  • 2013-05-03
相关资源
最近更新 更多