C# Faulty Kinect skeletal tracking mechanism or mistake in program(more likely the latter)

145 views Asked by At

I've been trying to write a program for Kinect using Skeletal Tracking that will determine whether or not there are people/a person(seated or standing) is in front of the Kinect.

The problem is that my program always outputs "false"(meaning it has detected no skeleton). After consulting the below links,

Kinect SDK player detection Kinect user Detection

I can't for my life find out why the program does this.Perhaps my Kinect has a faulty skeleton tracking mechanism, but I think it's far more likely there's a bug in my program. I'd truly appreciate any input.

 bool TryGettingSkeleton(AllFramesReadyEventArgs e) { 
        using (SkeletonFrame skeletonFrame=e.OpenSkeletonFrame())
        {
            int playerCount=0;
            if (skeletonFrame != null)
            {
                Skeleton[] skeletonData = new Skeleton[kinectSensorChooser1.Kinect.SkeletonStream.FrameSkeletonArrayLength];
                skeletonFrame.CopySkeletonDataTo(skeletonData);


                foreach (Skeleton skeleton in skeletonData)//check all the skeletons, see which ones are tracked as sitting/standing
                {
                    if (skeleton.TrackingState == SkeletonTrackingState.Tracked || skeleton.TrackingState == SkeletonTrackingState.PositionOnly)
                        playerCount++;
                }


                if (playerCount > 0)
                    return true;//there is at least one skeleton present
                else
                    return false;
            }

            else
            {
                return false;//no skeleton frame data, thus assume no skeleton
            }
        }//ends using

    }//ends TryGettingSkeleton method
0

There are 0 answers