您的位置:首页 > 编程语言

如何平滑处理Kinect采集的骨骼数据 | KinectAPI编程

2013-05-06 20:37 330 查看
1. What causes skeleton jitters?

Though the skeleton jitters could be caused by the application performance due to both software and hardware, there are several internal possible reasons for skeleton joints jittering. One of the main reasons is processing large amounts of data over a period of time during skeleton tracking. Because of the processing of large data, it's very difficult to calculate the accuracy of the joint movements.

2. Making skeleton movement softer

The Kinect for Windows SDK exposes some APIs for smoothing and filtering out the skeleton data. We can set smoothing parameters while setting up the skeleton stream data. The smoothing parameters solve the jittering problem by filtering the skeleton data and applying a smoothing algorithm to it. We have already seen that the SkeletonStream class has an overloaded Enable() method. This method accepts SmoothParameters as a parameter, which is a type of TransformSmoothParameters structure.

For example, the following code enables a skeleton stream using TransformSmoothParameters.
// create the smooth parameters
var smoothParameters = new TransformSmoothParameters
{
Correction = 0.1f,
JitterRadius = 0.05f,
MaxDeviationRadius = 0.05f,
Prediction = 0.1f,
Smoothing = 1.0f
};
// Enable the skeleton stream with smooth parameters
this.sensor.SkeletonStream.Enable(smoothParameters);

应用实例1:《Kinect应用开发实践 》 Page182

var parameters = new TransformSmoothParameters

{

    Smoothing = 0.5f,

    Correction = 0.5f,

    Prediction = 0.5f,

    JitterRadius = 0.05f,

    MaxDeviationRadius = 0.04f

  };

kinect.SkeletonStream.Enable(parameters);

// kinect.SkeletonStream.Enable(); // 以上等同于该指令的作用

应用实例2:《Programming with the Kinect for Windows SDK 》 Page134

参数设置与应用实例1相同,代码略

3. Smoothing parameters

TransformSmoothParameters is a public structure defined in the Microsoft. Kinect assembly. It has five public properties that enable the overall smoothing of skeleton data. The following table lists out the properties:





4. How to check if skeleton smoothing is enabled?

The SkeletonStream has a read-only property IsSmoothingEnabled to check if the smoothing is enabled. For example, you can use the property as follows:
bool isSmoothingEnable = this.sensor.SkeletonStream.IsSmoothingEnabled;
The IsSmoothingEnabled property is automatically set to true when the stream is
enabled with TransformSmoothParameters and false when the default Enable()
method is used.

5. Exponential smoothing

The Kinect for Windows SDK exposes an API to apply the smoothing parameter while enabling the skeleton stream and once it's applied, all the joint positions returned by the skeleton tracking engine will be smooth. The smoothing parameters
are applied to the data returned by the skeleton engine over time. The overall smoothing process uses statistical analysis to generate a moving average of joints, which reduces the noise. The Kinect for Windows SDK uses the Holt double exponential smoothing procedure to reduce the jitters from skeletal joint data. The exponential smoothing is applied to a series of time-based data to make a forecast.

The skeleton engine returns the skeleton frame in a regular time interval. The smoothing algorithm applies to each set of data and calculates a moving average based on the previous set of data. During the calculation of moving average, it uses
the values passed by the smoothing parameter. For example, from the following sample chart you can see the difference between the raw skeleton and smoothed data. If you noticed, the trend of data movement always remains the same as the original data but the deviation is less.



Applying smoothing on skeleton data could be very expensive in terms of application performance. This is because the skeleton stream data itself is massive, and applying smoothing filtering on it makes data processing slow and this highly depends on the parameters you are using.

本文摘自《Kinect for Windows SDK Programming Guide》 Abhijit Jana 著 PACKT Publishing (First Published 2012.12) 第六章:Human Skeleton Tracking
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐