在2682-2683帧之后,Kinect停止接听SkeletonFramesReady的电话。 程序不会崩溃,UI也不会冻结。看起来像一个缓冲区问题或者什么东西被称为一堆不需要的时候。有什么事情似乎不正常吗?
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
bool gotData = false;
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null && skeletonData != null)
{
skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo(skeletonData);
gotData = true;
}
}
if (gotData)
{
using (DrawingContext dc = this.drawingGroup.Open())
{
// Draw a transparent background to set the render size
dc.DrawRectangle(Brushes.Transparent, null, new Rect(0.0, 0.0, DrawingToolsFactory.RenderWidth, DrawingToolsFactory.RenderHeight));
// Grab the first skeleton
Skeleton currentSkeleton = (from s in skeletonData
where s.TrackingState ==
SkeletonTrackingState.Tracked
select s).FirstOrDefault();
if (currentSkeleton == null) return;
if (currentSkeleton.TrackingState == SkeletonTrackingState.Tracked)
{
this.DrawBonesAndJoints(currentSkeleton, dc);
Joint joint = currentSkeleton.Joints[JointType.ShoulderCenter];
}
else if (currentSkeleton.TrackingState == SkeletonTrackingState.PositionOnly)
{
dc.DrawEllipse(
DrawingToolsFactory.CreateCenterPointBrush(),
null,
this.SkeletonPointToScreen(currentSkeleton.Position),
DrawingToolsFactory.BodyCenterThickness,
DrawingToolsFactory.BodyCenterThickness);
}
}
// prevent drawing outside of our render area
this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, DrawingToolsFactory.RenderWidth, DrawingToolsFactory.RenderHeight));
}
}
}