none
How to create boundaries to detect skeleton if it exits RRS feed

  • Question

  • As stated how can i create the boundaries to detect skeletons from exiting the set boundary.

    The original:

    if (skeleton.ClippedEdges.HasFlag(FrameEdges.Bottom))
                {
                    drawingContext.DrawRectangle(
                        Brushes.Red,
                        null,
                        new Rect(0, RenderHeight - ClipBoundsThickness, RenderWidth, ClipBoundsThickness));
                }

    Editted code:

    Rect myRect1 = new Rect(160, 0.0, RenderWidth, RenderHeight);
               
                RectangleGeometry myRectangleGeometry1 = new RectangleGeometry();
                myRectangleGeometry1.Rect = myRect1;

    if (skeleton.ClippedEdges.HasFlag(myRect1.Bottom))
                {
                    drawingContext.DrawRectangle(
                        Brushes.Red,
                        null,
                        new Rect(0, RenderHeight - ClipBoundsThickness, RenderWidth, ClipBoundsThickness));
                }

    In my editted code as underlined, that part doesnt work, can someone enlighten me on how i should be doing it.

    Thanks in advance!

    Tuesday, November 26, 2013 10:40 AM

Answers

  • If you want to know if a "Tracked skeleton" is no longer visible, check the skeleton's "TrackingState" property. If you know the skeleton id, you can do something like this:

    int PlayerOfInterest = -1;
    
    private void OnSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
    {
        using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
        {
            if (null != skeletonFrame)
            {
                skeletonFrame.CopySkeletonDataTo(this.skeletons);
            }
        }
    
        // keep track of a specific player
        if (PlayerOfInterest == -1)
        {
            // find the first tracked person we find.
            foreach (Skeleton skeleton in this.skeletons)
            {
                if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                {
                    PlayerOfInterest = skeleton.TrackingId;
                }
            }
    
        }
    
        if (null != this.skeletons && this.skeletons[PlayerOfInterest].TrackingState == SkeletonTrackingState.NotTracked)
        {
            //do something since they left
            PlayerOfInterest = -1;
        }
    
    }

    http://msdn.microsoft.com/en-us/library/hh973074.aspx

    http://msdn.microsoft.com/en-us/library/microsoft.kinect.skeleton.trackingstate.aspx

    Clipping only lets you know that part of their body is outside the field of view. Keep in mind, if the boundary is not the field of view of the camera, then you need develop your our bounds checking based on the skeleton joint coordinates that are mapped to the depth frame.


    Carmine Sirignano - MSFT

    Tuesday, November 26, 2013 8:28 PM

All replies

  • If you want to know if a "Tracked skeleton" is no longer visible, check the skeleton's "TrackingState" property. If you know the skeleton id, you can do something like this:

    int PlayerOfInterest = -1;
    
    private void OnSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
    {
        using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
        {
            if (null != skeletonFrame)
            {
                skeletonFrame.CopySkeletonDataTo(this.skeletons);
            }
        }
    
        // keep track of a specific player
        if (PlayerOfInterest == -1)
        {
            // find the first tracked person we find.
            foreach (Skeleton skeleton in this.skeletons)
            {
                if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                {
                    PlayerOfInterest = skeleton.TrackingId;
                }
            }
    
        }
    
        if (null != this.skeletons && this.skeletons[PlayerOfInterest].TrackingState == SkeletonTrackingState.NotTracked)
        {
            //do something since they left
            PlayerOfInterest = -1;
        }
    
    }

    http://msdn.microsoft.com/en-us/library/hh973074.aspx

    http://msdn.microsoft.com/en-us/library/microsoft.kinect.skeleton.trackingstate.aspx

    Clipping only lets you know that part of their body is outside the field of view. Keep in mind, if the boundary is not the field of view of the camera, then you need develop your our bounds checking based on the skeleton joint coordinates that are mapped to the depth frame.


    Carmine Sirignano - MSFT

    Tuesday, November 26, 2013 8:28 PM
  • I have tried the code but the word "this.skeletons" is highlighted. It says Error       'Microsoft.Samples.Kinect.SkeletonBasics.MainWindow' does not contain a definition for 'skeletons' and no extension method 'skeletons' accepting a first argument of type 'Microsoft.Samples.Kinect.SkeletonBasics.MainWindow' could be found (are you missing a using directive or an assembly reference?)    C:\Users\User\Desktop\FYP\SkeletonBasics-WPF\MainWindow.xaml.cs    324    59    SkeletonBasics-WPF

    Can i get some help for this.

    Thanks in advance!

    Zong li

     private int PlayerOfInterest = -1;
    
            private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
            {
                
    
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                {
                    if (null != skeletonFrame)
                    {
                        
                        skeletonFrame.CopySkeletonDataTo(this.skeletons);
                    }
                }
    
                // keep track of a specific player
                if (PlayerOfInterest == -1)
                {
                    // find the first tracked person we find.
                    foreach (Skeleton skeleton in this.skeletons)
                    {
                        if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                        {
                            PlayerOfInterest = skeleton.TrackingId;
                        }
                    }
    
                }
    
                if (null != this.skeletons && this.skeletons[PlayerOfInterest].TrackingState == SkeletonTrackingState.NotTracked)
                {
                    Process.Start("wmplayer.exe", "C:\\Users\\User\\Downloads\\Test.wma");
                    PlayerOfInterest = -1;
                }
    
            }



    Thursday, January 23, 2014 1:57 PM