none
Recognize gesture when its not performed RRS feed

  • Question

  • Hello!

    I am currently working on finding tracking id upon gesture is performed in order to track one person.

    I am able to find tracking id but it is recognizing the first body that enters the frame.

    When I debug, code recognize as the gesture is performed.

    Any help would be very appreciated.

    Thank you for your time!

    Here is where I try to find tracking id using gesture:

          /// <summary> Set the body index </summary>
            public ulong GetBodyID()
            {
                //if (SetBodyID < 1)
                //{
                    using (var idframe = this.vgbFrameReader.CalculateAndAcquireLatestFrame())
                    {
                        //if (idframe != null)
                        //{
                            Debug.WriteLine("enter sandman");
    
                            foreach (var gesture in this.vgbFrameSource.Gestures)
                            {
                                if (gesture.GestureType == GestureType.Discrete)
                                {
    
                                    if (SetBodyID < 1)
                                    {
                                        //if (gesture.Name.Equals(this.steerLeftGestureName))
                                        if (gesture.Name.Equals(this.maxTurnLeftGestureName) || gesture.Name.Equals(this.steerLeftGestureName))
                                        //if (keepStraight == true)
                                        {
                                            Debug.WriteLine("Gesture Detected");
                                            SetBodyID = TrackingId;
                                            // Debug.WriteLine(SetBodyID);
                                        }
                                        else
                                        {
                                            //SetBodyID = 0;
                                        }
                                    }
                                }
                            }
                        //}
                        
                    }
               // }
                Debug.Write("Tracking ID:");
                Debug.WriteLine(SetBodyID);
    
                return SetBodyID;
            }

    Here is where I call tracking ID class and retrieve body index:

    private int GetActiveBodyIndex()
            {
                int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
                //Debug.Listeners.Add(new ConsoleTraceListener());
                if (findBodyIndex < 0)
                {
    
                    for (int i = 0; i < maxBodies; ++i)
                    {
                        Body body = this.bodies[i];
                        ulong trackingId = body.TrackingId;
    
                        // visualize the new gesture data
                        //if (body.TrackingId != this.gestureDetector.TrackingId)
                        //{
                        // if the tracking ID changed, update the detector with the new value
                        this.gestureDetector.TrackingId = body.TrackingId;
                        //}
    
                        activeBodyid = this.gestureDetector.GetBodyID();
                    }
    
                }
                else
                {
                    //findBodyIndex = -1;
                }
                if (activeBodyid > 0)
                {
                    for (int i = 0; i < maxBodies; ++i)
                    {
                        if (activeBodyid == bodies[i].TrackingId)
                        {
                            findBodyIndex = i;
                            break;
                        }
                    }
                }
                Debug.Write("Tracking index:");
                Debug.WriteLine(findBodyIndex);
                    return findBodyIndex;
                
            }

    Tuesday, August 23, 2016 4:47 AM