使用Kinect测量物体高度

6
例如,我站在Kinect前面。 Kinect可以识别关节,并将其作为数据结构公开。到目前为止,我很清楚。
因此,我们可以将高度定义为Head joint - ((LeftAnkle + RightAnkle) / 2)的差吗?
我尝试过三角函数公式,但遇到了两个问题。一个是识别视野中的人物。第二个是确定头部和脚底的确切位置。
我尝试使用点云,但不知道如何生成特定于人的点云。 我的意思是不包括背景对象。
请建议一些关于如何使用Kinect计算人的身高的想法?

你使用的是哪个API来访问Kinect? - Richard Povinelli
我正在使用Windows Kinect API。 - Dinesh
也请查看这个答案 - Vito Gentile
可能是使用Kinect测量人的身高的重复问题。 - Vito Gentile
4个回答

4
您可以将头部联合转换为全局坐标系,无需进行任何计算。在全局坐标中,y坐标将是他的高度。
您需要做的就是检查头部联合所在的像素,并将像素+深度信息转换为毫米单位的单词坐标空间。
我不知道您正在使用哪种API,但如果它能够分割人体并返回其关节,那么您可能正在使用OpenNI/NITE或Microsoft SDK。它们都有一个函数,将像素+深度坐标转换为毫米制的x、y、z坐标。我不知道确切的函数名称是什么,但它们的名称应该类似于: depth_to_mm,或disparity_to_mm。您需要查看两个文档以找到它,或者您可以自己完成。
这个网站提供了如何将深度转换为毫米的信息:http://nicolas.burrus.name/index.php/Research/KinectCalibration

我已经尝试过这种方法。我几乎可以正确地获取深度信息,可以接受1或2英寸的误差。但是当我检查Y坐标值时,它根本不与原始高度匹配,甚至不是一半的值。Y坐标值与原始值之间存在巨大差异。 - Dinesh
它有点像,我的身高是5.5英尺。当取y坐标时,它显示1.2英尺。有任何想法,可能是什么错误? - Dinesh
你是在将毫米转换为英尺吗? - Ian Medeiros

3

我已经提取了两个点 - 头部和左脚(或右脚),然后计算这些点之间的欧几里得距离,发现距离有4英寸的变化。我的测试结果令人满意,因此我们正在使用这种方法作为临时解决方案。


1

这是一个旧问题,但我在这里找到了一个非常好的解释和示例。它还解释了高度不仅仅是头部和脚踝点的函数,而是以下线段的函数:

  • 头 - 肩中心
  • 肩中心 - 脊柱
  • 脊柱 - 臀中心
  • 臀中心 - 左膝盖或右膝盖
  • 左膝盖/右膝盖 - 左脚踝/右脚踝
  • 左脚踝/右脚踝 - 左脚/右脚

0

这里是Kinect SDK 2.0的公式。完整项目可在https://github.com/jhealy/kinect2/tree/master/020-FaceNSkin_HowTallAmI中获取...

using System;
using Microsoft.Kinect;

// Skeleton is now Bones
public enum BodyHeightMeasurementSystem
{
    Meters = 0, Imperial = 1
}

public static class BodyHeightExtension
{
// change this to change the way values are returned, by default everything is meters
public static BodyHeightMeasurementSystem MeasurementSystem = BodyHeightMeasurementSystem.Meters;

/// <summary>
/// Get Height of a body in CM
/// </summary>
/// <param name="TargetBody">used for extension method purposes - uses should not see</param>
/// <returns>
/// positive value: height in meters
/// -1.0 : null body passed in
/// -2.0 : body not tracked, no height available
/// </returns>
public static double Height( this Body TargetBody )
{
    if ( TargetBody == null ) return -1.0;
    if (TargetBody.IsTracked == false) return -2.0;

    const double HEAD_DIVERGENCE = 0.1;

    Joint _head = TargetBody.Joints[JointType.Head];
    Joint _neck = TargetBody.Joints[JointType.Neck];

    // var spine = skeleton.Joints[JointType.Spine]; // ?
    Joint _spine = TargetBody.Joints[JointType.SpineShoulder];
    // var waist = skeleton.Joints[JointType.HipCenter];  // ?
    // jeh: spinemid is ignored
    Joint _waist = TargetBody.Joints[JointType.SpineBase];
    Joint _hipLeft = TargetBody.Joints[JointType.HipLeft];
    Joint _hipRight = TargetBody.Joints[JointType.HipRight];
    Joint _kneeLeft = TargetBody.Joints[JointType.KneeLeft];
    Joint _kneeRight = TargetBody.Joints[JointType.KneeRight];
    Joint _ankleLeft = TargetBody.Joints[JointType.AnkleLeft];
    Joint _ankleRight = TargetBody.Joints[JointType.AnkleRight];
    Joint _footLeft = TargetBody.Joints[JointType.FootLeft];
    Joint _footRight = TargetBody.Joints[JointType.FootRight];

    // Find which leg is tracked more accurately.
    int legLeftTrackedJoints = NumberOfTrackedJoints(_hipLeft, _kneeLeft, _ankleLeft, _footLeft);
    int legRightTrackedJoints = NumberOfTrackedJoints(_hipRight, _kneeRight, _ankleRight, _footRight);

    double legLength = legLeftTrackedJoints > legRightTrackedJoints ? Length(_hipLeft, _kneeLeft, _ankleLeft, _footLeft) 
        : Length(_hipRight, _kneeRight, _ankleRight, _footRight);

    // default is meters.  adjust if imperial to feet
    double _retval = Length(_head, _neck, _spine, _waist) + legLength + HEAD_DIVERGENCE;
    if (MeasurementSystem == BodyHeightMeasurementSystem.Imperial) _retval = MetricHelpers.MetersToFeet(_retval);

    return _retval;
}

/// <summary>
/// Returns the upper height of the specified skeleton (head to waist). Useful whenever Kinect provides a way to track seated users.
/// </summary>
/// <param name="skeleton">The specified user skeleton.</param>
/// <returns>The upper height of the skeleton in meters.</returns>
public static double UpperHeight( this Body TargetBody )
{
    Joint _head = TargetBody.Joints[JointType.Head];
    // used to be ShoulderCenter. Think its SpineMid now
    Joint _neck = TargetBody.Joints[JointType.SpineMid];
    // .Spine is now .SpineShoulder
    Joint _spine = TargetBody.Joints[JointType.SpineShoulder];
    // HipCenter is now SpineBase
    Joint _waist = TargetBody.Joints[JointType.SpineBase];

    return Length(_head, _neck, _spine, _waist);
}

/// <summary>
/// Returns the length of the segment defined by the specified joints.
/// </summary>
/// <param name="p1">The first joint (start of the segment).</param>
/// <param name="p2">The second joint (end of the segment).</param>
/// <returns>The length of the segment in meters.</returns>
public static double Length(Joint p1, Joint p2)
{
    return Math.Sqrt(
        Math.Pow(p1.Position.X - p2.Position.X, 2) +
        Math.Pow(p1.Position.Y - p2.Position.Y, 2) +
        Math.Pow(p1.Position.Z - p2.Position.Z, 2));
}

/// <summary>
/// Returns the length of the segments defined by the specified joints.
/// </summary>
/// <param name="joints">A collection of two or more joints.</param>
/// <returns>The length of all the segments in meters.</returns>
public static double Length(params Joint[] joints)
{
    double length = 0;

    for (int index = 0; index < joints.Length - 1; index++)
    {
        length += Length(joints[index], joints[index + 1]);
    }

    return length;
}

/// <summary>
/// Given a collection of joints, calculates the number of the joints that are tracked accurately.
/// </summary>
/// <param name="joints">A collection of joints.</param>
/// <returns>The number of the accurately tracked joints.</returns>
public static int NumberOfTrackedJoints(params Joint[] joints)
{
    int trackedJoints = 0;
    foreach (var joint in joints)
    {
        // if (joint.TrackingState == JointTrackingState.Tracked)
        if ( joint.TrackingState== TrackingState.Tracked )
        {
            trackedJoints++;
        }
    }
    return trackedJoints;
}

/// <summary>
/// Scales the specified joint according to the specified dimensions.
/// </summary>
/// <param name="joint">The joint to scale.</param>
/// <param name="width">Width.</param>
/// <param name="height">Height.</param>
/// <param name="MaxX">Maximum X.</param>
/// <param name="MaxY">Maximum Y.</param>
/// <returns>The scaled version of the joint.</returns>
public static Joint ScaleTo(Joint joint, int width, int height, float MaxX, float MaxY)
{
    // SkeletonPoint position = new SkeletonPoint()
    Microsoft.Kinect.CameraSpacePoint position = new Microsoft.Kinect.CameraSpacePoint()
    {
        X = Scale(width, MaxX, joint.Position.X),
        Y = Scale(height, MaxY, -joint.Position.Y),
        Z = joint.Position.Z
    };
    joint.Position = position;
    return joint;
}

/// <summary>
/// Scales the specified joint according to the specified dimensions.
/// </summary>
/// <param name="joint">The joint to scale.</param>
/// <param name="width">Width.</param>
/// <param name="height">Height.</param>
/// <returns>The scaled version of the joint.</returns>
public static Joint ScaleTo(Joint joint, int width, int height)
{
    return ScaleTo(joint, width, height, 1.0f, 1.0f);
}

/// <summary>
/// Returns the scaled value of the specified position.
/// </summary>
/// <param name="maxPixel">Width or height.</param>
/// <param name="maxBody">Border (X or Y).</param>
/// <param name="position">Original position (X or Y).</param>
/// <returns>The scaled value of the specified position.</returns>
private static float Scale(int maxPixel, float maxBody, float position)
{
    float value = ((((maxPixel / maxBody ) / 2) * position) + (maxPixel / 2));

    if (value > maxPixel)
    {
        return maxPixel;
    }

    if (value < 0)
    {
        return 0;
    }

    return value;
}

}


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接