none
Detect User Activation RRS feed

  • Question

  • Is there an event I can attach to in order to detect a user has entered Kinect's line of sight.  I want to be able to detect a user walk into view and have kinect someone is there and kick off some code.  Also an event to know if there is no current user in front of Kinect?
    Thursday, August 14, 2014 12:47 PM

All replies

  • Take a look at the BodySample-WPF sample.  Basically you'll have BodyFrameReader that you'll connect and in its FrameArrived event you can loop through the bodies.  If there are none - there will be nothing to iterate over.

                       

    foreach(varbody inthis.bodies)

    {

                           

    if(body.IsTracked)

    {


                            }

    • Proposed as answer by kjwinkel Thursday, August 14, 2014 12:53 PM
    Thursday, August 14, 2014 12:53 PM
  • I used a standard event.

    I'm looking for a method for catching the "depart" or "exit", but this works for onChange.

    Plus I put the Kinect logic into a Singleton as KinectSolution, put this there in separate class unlike all the samples do.

            /// <summary>
            ///  body count change event used by consumer to get change.
            /// </summary>
            public event BodyCountChanged BodyCountChangedEvent;
            public delegate void BodyCountChanged(object source, BodyCountChangedEventArgs e);

       /// <summary>
        /// BodyCountChangedEventArgs
        /// </summary>
        /// 
        public class BodyCountChangedEventArgs : EventArgs
        {
            public int oldValue;
            public int newBodyCount;
    
            public BodyCountChangedEventArgs(int oldValue, int newBodyCount)
            {
                this.oldValue = oldValue;
                this.newBodyCount = newBodyCount;
            }
        }

           private int _BodyCount;
           public int bodyCount
           {
               get {return _BodyCount;}
               private set
               {
                   if (this._BodyCount != value)
                   {
                       int oldValue = _BodyCount;
                       this._BodyCount = value;
                       this.StatusText = "Body Count Changed=" + _BodyCount;
                       // @TODO: occupancyChanged should be removed too, keeping it for now. 
                       //this.occupancyChanged();
                       BodyCountChangedEvent(this, new BodyCountChangedEventArgs(oldValue, value));
                   }
               }
           }


    Ken

    Tuesday, September 16, 2014 2:55 PM
  • The problem were having is that given the contours of our booth, the Kinect doesn't always pickup a body, due to obstructed views.  The body stuff is pretty finicky.

    http://msdn.microsoft.com/en-us/library/windowspreview.kinect.depthframe.aspx

    Trying depthFrame

    The data for this frame is stored as 16-bit unsigned integers, where each value represents the distance in millimeters.      The maximum depth distance is 8 meters, although reliability starts to degrade at around 4.5 meters.      Developers can use the depth frame to build custom tracking algorithms in cases where the BodyFrame isn’t enough.

    Basically, if checksum the numbers (general distance to back of wall), when a body walks in the checksum value will drop. 

    The documentation suggests that one could write their own approach using this raw data.  When we need more than simple Boolean of IsSomebodyPresent() is there any helper classes for "custom tracking algos?" Ideas suggestions?


    Ken

    Tuesday, September 23, 2014 7:41 PM
  • Watch the 7th MVA session that Casey Meekhof did. He describes doing depth analysis to understand motion in the scene. Likely useful for you...

    Link to the first session is here:

    http://www.microsoftvirtualacademy.com/training-courses/programming-kinect-for-windows-v2-jump-start

    Thanks, Rob


    Rob Relyea [MSFT] http://twitter.com/rrelyea

    Wednesday, September 24, 2014 12:03 AM