本文整理汇总了C#中SkeletonFrameReadyEventArgs.OpenSkeletonFrame方法的典型用法代码示例。如果您正苦于以下问题:C# SkeletonFrameReadyEventArgs.OpenSkeletonFrame方法的具体用法?C# SkeletonFrameReadyEventArgs.OpenSkeletonFrame怎么用?C# SkeletonFrameReadyEventArgs.OpenSkeletonFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkeletonFrameReadyEventArgs
的用法示例。
在下文中一共展示了SkeletonFrameReadyEventArgs.OpenSkeletonFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SensorSkeletonFrameReady
/// <summary>
/// Handler for the Kinect sensor's SkeletonFrameReady event
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="skeletonFrameReadyEventArgs">event arguments</param>
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs skeletonFrameReadyEventArgs)
{
// Even though we un-register all our event handlers when the sensor
// changes, there may still be an event for the old sensor in the queue
// due to the way the KinectSensor delivers events. So check again here.
if (this.KinectSensor != sender)
{
return;
}
using (SkeletonFrame skeletonFrame = skeletonFrameReadyEventArgs.OpenSkeletonFrame())
{
if (null != skeletonFrame)
{
try
{
// Copy the skeleton data from the frame to an array used for temporary storage
skeletonFrame.CopySkeletonDataTo(this.skeletons);
var accelerometerReading = this.KinectSensor.AccelerometerGetCurrentReading();
// Hand data to Interaction framework to be processed
this.interactionStream.ProcessSkeleton(this.skeletons, accelerometerReading, skeletonFrame.Timestamp);
}
catch (InvalidOperationException)
{
// SkeletonFrame functions may throw when the sensor gets
// into a bad state. Ignore the frame in that case.
}
}
}
}
示例2: OnFrameArrived
/// <summary>
/// Raises the frame arrived event.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">E.</param>
private void OnFrameArrived(object sender, SkeletonFrameReadyEventArgs e)
{
using (var frame = e.OpenSkeletonFrame())
{
if (frame == null)
{
return;
}
var foundedSkeletons = new KinectV1::Microsoft.Kinect.Skeleton[frame.SkeletonArrayLength];
frame.CopySkeletonDataTo(foundedSkeletons);
var skeletons = foundedSkeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked);
foreach (var skeleton in skeletons)
{
var trameSkeleton = CreateSkeleton(skeleton);
_lastSkeleton = trameSkeleton;
FireNewSkeleton(trameSkeleton);
}
}
}