Esempio n. 1
0
        internal bool ShouldIncludeEvent(DecodedEventWrapper etwEvent)
        {
            // If there are no filters, then we should include the event
            if (null == this.filters)
            {
                return(true);
            }

            // If we have filters, then don't include the event unless the
            // filters effectively ask for it to be included.
            bool      includeEvent = false;
            Closeness closeness    = Closeness.NoMatch;

            // Go through each filter and compare ...
            foreach (FilterElement filterElement in this.filters)
            {
                // Check if the event matches the current filter. If it matches,
                // check whether the filter asks for the event to be included or
                // excluded.
                bool      tempIncludeEvent;
                Closeness tempCloseness;
                this.MatchEventWithFilter(
                    filterElement,
                    etwEvent,
                    out tempCloseness,
                    out tempIncludeEvent);

                // If this filter is a closer match than previously encountered
                // filters, then update our decision to include or exclude the
                // event.
                // If this filter is not a closer match than previously
                // encountered filters, then we do not update our decision.
                if (tempCloseness > closeness)
                {
                    System.Fabric.Interop.Utility.ReleaseAssert(tempCloseness != Closeness.NoMatch, string.Empty);
                    includeEvent = tempIncludeEvent;
                    closeness    = tempCloseness;

                    if (Closeness.MaxCloseness == closeness)
                    {
                        // We already found the closest possible match. We can't
                        // find a closer match than this. So break out of the loop.
                        break;
                    }
                }
            }

            return(includeEvent);
        }
Esempio n. 2
0
        private void MatchEventWithFilter(FilterElement filterElement, DecodedEventWrapper etwEvent, out Closeness closeness, out bool includeEvent)
        {
            includeEvent = false;

            // Figure out if we have a match and if so how close is the match
            closeness = this.ComputeCloseness(filterElement, etwEvent);

            // If we have a match, figure out whether the event should be
            // included or not
            if (closeness > Closeness.NoMatch)
            {
                includeEvent = filterElement.Level >= etwEvent.Level;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the body frame data arriving from the sensor
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            this.previousBodyFrameTime = currentBodyFrameTime;
            this.currentBodyFrameTime  = DateTime.Now;

            bool dataReceived = false;

            using (var bodyFrame = e.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (this.bodies == null)
                    {
                        this.bodies = new Body[bodyFrame.BodyCount];
                    }
                    dataReceived = true;

                    // update body data
                    // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
                    // As long as those body objects are not disposed and not set to null in the array,
                    // those body objects will be re-used.
                    bodyFrame.GetAndRefreshBodyData(this.bodies);

                    bool gotFaceResult = false;

                    // iterate through each face source
                    for (int i = 0; i < this.bodyCount; i++)
                    {
                        // check if a valid face is tracked in this face source
                        if (this.faceFrameSources[i].IsTrackingIdValid)
                        {
                            // check if we have valid face frame results
                            if (this.faceFrameResults[i] != null)
                            {
                                faceIndicator.Fill = new SolidColorBrush(Colors.Red);
                                handleFaceFrameResults(i, this.faceFrameResults[i]);
                                if (!gotFaceResult)
                                {
                                    gotFaceResult = true;
                                }
                            }
                        }
                        else
                        {
                            // check if the corresponding body is tracked
                            if (this.bodies[i].IsTracked)
                            {
                                // update the face frame source to track this body
                                this.faceFrameSources[i].TrackingId = this.bodies[i].TrackingId;
                            }
                        }
                    }

                    if (!gotFaceResult)
                    {
                        // if no faces were gotten then this indicates one of the following:
                        // a body was not tracked
                        // a body was tracked but the corresponding face was not tracked
                        // a body and the corresponding face was tracked though the face box or the face points were not valid

                        // if we cant find a face then we can assume the display is not being looked at
                        //lookAwayTimer += (currentBodyFrameTime - previousBodyFrameTime).TotalSeconds;
                        //Debug.WriteLine("no face lookAway:" + lookAwayTimer.ToString());
                        faceIndicator.Fill = new SolidColorBrush(Colors.Orange);
                    }
                }
            }

            if (dataReceived)
            {
                foreach (Body body in this.bodies)
                {
                    if (body.IsTracked)
                    {
                        IReadOnlyDictionary <JointType, Joint> joints = body.Joints;

                        if (joints.ContainsKey(JointType.Head))
                        {
                            CameraSpacePoint position = joints[JointType.Head].Position;
                            if (position.Z < 0)
                            {
                                position.Z = InferredZPositionClamp;
                            }
                            //Debug.WriteLine("z:" + position.Z.ToString());
                            if (position.Z <= 0.68)
                            {
                                closeness = Closeness.Close;
                            }
                            else if (position.Z <= 1)
                            {
                                closeness = Closeness.Medium;
                            }
                            else
                            {
                                closeness = Closeness.Far;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the body frame data arriving from the sensor
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            this.previousBodyFrameTime = currentBodyFrameTime;
            this.currentBodyFrameTime = DateTime.Now;

            bool dataReceived = false;

            using (var bodyFrame = e.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (this.bodies == null)
                    {
                        this.bodies = new Body[bodyFrame.BodyCount];
                    }
                    dataReceived = true;

                    // update body data
                    // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
                    // As long as those body objects are not disposed and not set to null in the array,
                    // those body objects will be re-used.
                    bodyFrame.GetAndRefreshBodyData(this.bodies);

                    bool gotFaceResult = false;

                    // iterate through each face source
                    for (int i = 0; i < this.bodyCount; i++)
                    {
                        // check if a valid face is tracked in this face source
                        if (this.faceFrameSources[i].IsTrackingIdValid)
                        {
                            // check if we have valid face frame results
                            if (this.faceFrameResults[i] != null)
                            {
                                faceIndicator.Fill = new SolidColorBrush(Colors.Red);
                                handleFaceFrameResults(i, this.faceFrameResults[i]);
                                if (!gotFaceResult)
                                {
                                    gotFaceResult = true;
                                }
                            }
                        }
                        else
                        {
                            // check if the corresponding body is tracked 
                            if (this.bodies[i].IsTracked)
                            {
                                // update the face frame source to track this body
                                this.faceFrameSources[i].TrackingId = this.bodies[i].TrackingId;
                            }
                        }
                    }

                    if (!gotFaceResult)
                    {
                        // if no faces were gotten then this indicates one of the following:
                        // a body was not tracked 
                        // a body was tracked but the corresponding face was not tracked
                        // a body and the corresponding face was tracked though the face box or the face points were not valid

                        // if we cant find a face then we can assume the display is not being looked at
                        //lookAwayTimer += (currentBodyFrameTime - previousBodyFrameTime).TotalSeconds;
                        //Debug.WriteLine("no face lookAway:" + lookAwayTimer.ToString());
                        faceIndicator.Fill = new SolidColorBrush(Colors.Orange);
                    }
                }
            }

            if (dataReceived)
            {
                foreach (Body body in this.bodies)
                {
                    if (body.IsTracked)
                    {
                        IReadOnlyDictionary<JointType, Joint> joints = body.Joints;
                        
                        if (joints.ContainsKey(JointType.Head))
                        {
                            CameraSpacePoint position = joints[JointType.Head].Position;
                            if (position.Z < 0)
                            {
                                position.Z = InferredZPositionClamp;
                            }
                            //Debug.WriteLine("z:" + position.Z.ToString());
                            if (position.Z <= 0.68)
                            {
                                closeness = Closeness.Close;
                            } else if (position.Z <= 1)
                            {
                                closeness = Closeness.Medium;
                            } else
                            {
                                closeness = Closeness.Far;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 public PersonViewModel(string name, Closeness closeness)
 {
     this.Name      = name;
     this.Closeness = closeness;
 }
 public PersonViewModel(string name, Closeness closeness)
 {
     this.Name = name;
     this.Closeness = closeness;
 }