1

So currently I have a bool PersonDetected which is always set to false UNLESS a Skeleton is detected. But currently when a SkeletonTrackingState is marked as Tracked, but PersonDetected is still set to false. Thanks in advance

My Code

Skeleton skeletons = new Skeleton();

            if ((skeletons.TrackingState == SkeletonTrackingState.Tracked ||
                skeletons.TrackingState == SkeletonTrackingState.PositionOnly) &
                skeletons.TrackingState != SkeletonTrackingState.NotTracked)
                {
                    PersonDetected = true;
                }
Liam McInroy
  • 4,339
  • 5
  • 32
  • 53

2 Answers2

1

I discovered the reason that it wasn't registering was because skeletons was just a variable, not a Skeleton being tracked, so I added the following code to make sure that it worked:

Skeleton skeletons = new Skeleton();

            skeletons = (from s in allSkeletons
                         where s.TrackingState == SkeletonTrackingState.Tracked ||
                         s.TrackingState == SkeletonTrackingState.PositionOnly
                         select s).FirstOrDefault();

            if (skeletons == null)
            {
                return;
            }

            if ((skeletons.TrackingState == SkeletonTrackingState.Tracked ||
                skeletons.TrackingState == SkeletonTrackingState.PositionOnly))
            {
                PersonDetected = true;
            }
Liam McInroy
  • 4,339
  • 5
  • 32
  • 53
0

Debug "diff". I'll bet it`s higher than 9

After that debug parts where you're incrementing diff.

Fixus
  • 4,631
  • 10
  • 38
  • 67