protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs)
        {
            if (!Configuration.dualSwipeNavigation) return;
            try
            {
                if (Math.Abs(_leftHandGestrue.Timestamp - _rightHandGestrue.Timestamp) > Epsilon)
                {
                    return;
                }

                if (_leftHandGestrue.Gesture == GesturesEnum.SwipeToLeft && _rightHandGestrue.Gesture == GesturesEnum.SwipeToRight)
                {
                    LogString.Log("Event: SwipeOut");
                    Raise(() => ParallelSwipeDetected(this, new SwipeEventArgs(GesturesEnum.SwipeOut)));
                }
                if (_leftHandGestrue.Gesture == GesturesEnum.SwipeToRight && _rightHandGestrue.Gesture == GesturesEnum.SwipeToLeft)
                {
                    LogString.Log("Event: SwipeIn");
                    Raise(() => ParallelSwipeDetected(this, new SwipeEventArgs(GesturesEnum.SwipeIn)));
                }
            }
            catch(Exception e)
            {
                System.Console.WriteLine("wacek");
            }
        }
        protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs)
        {
            var frames = _framesCollector.GetFrames(LastFrameTimestamp).ToList();
            if (frames.Count == 0)
            {
                return;
            }

            var torsoPosHistory = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == TJointType.Spine)).ToList();
            var LeftHandPosHistory = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == TJointType.HandLeft)).ToList();
            var RightHandPosHistory = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == TJointType.HandRight)).ToList();

            var lastLeftHandFrame = LeftHandPosHistory.Last();
            var lastRightHandFrame = RightHandPosHistory.Last();
            var lastTorsoFrame = torsoPosHistory.Last();

            var diffLeft = lastTorsoFrame.Position.Z - lastLeftHandFrame.Position.Z;
            var diffRight = lastTorsoFrame.Position.Z - lastRightHandFrame.Position.Z;

            if (ignoredCalls > 0)
            {
                ignoreCallsTrigger = true;
                ignoredCalls--;
                return;
            }
            else if (ignoreCallsTrigger == true)
            {
                ignoreCallsTrigger = false;
                LeftLastPosition = lastLeftHandFrame.Position;
                RightLastPosition = lastRightHandFrame.Position;
                LastHandsDistance = CalculateDistance(lastLeftHandFrame, lastRightHandFrame);
            }

            Calibrate(diffLeft, diffRight);

            bool left = LeftHandActive(diffLeft, lastLeftHandFrame.Position);
            bool right = RightHandActive(diffRight, lastRightHandFrame.Position);

            if (left && right)
            {
                if (!bothHandsActivated)
                {
                    bothHandsActivated = true;
                    LastHandsDistance = CalculateDistance(lastLeftHandFrame, lastRightHandFrame);
                    LogString.Log("BothHands Activated");
                }

                NavigateByBothHands(lastLeftHandFrame, lastRightHandFrame, frames);
            }
            else if (left)
            {
                NavigateByLeftHand(lastLeftHandFrame, frames);
            }
            else if (right)
            {
                NavigateByRightHand(lastRightHandFrame, frames);
            }
        }
Exemple #3
0
        protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs)
        {
            var frames = _framesCollector.GetFrames(LastFrameTimestamp).ToList();
            if (frames.Count == 0)
            {
                return;
            }

            var LeftHandPosHistory = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == TJointType.HandLeft)).ToList();

            var transitionVector = new Vector3() { X = LeftHandPosHistory.Last().Position.X - LeftHandPosHistory[0].Position.X, Y = LeftHandPosHistory.Last().Position.Y - LeftHandPosHistory[0].Position.Y };

            Raise(() => RaiseEvent(frames, transitionVector, 0, ControlType.RIGHT_HAND));
        }
Exemple #4
0
        private void FramesCollectorOnFrameReady(object sender, FrameReadyEventArgs frameReadyEventArgs)
        {
            if (_analyzeExtensions.Any(a => !a.CanAnalyze()))
            {
                return;
            }

            var milis = DateTime.Now.Ticks;

            Analyze(frameReadyEventArgs);

            var passed = DateTime.Now.Ticks - milis;

            if (passed > -1)
            {
                //LogString.Log(this.GetType().Name + " took: " + passed);
            }
        }
Exemple #5
0
        protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs)
        {
            if (!Configuration.handNavigation) return;

            var frames = _framesCollector.GetFrames(LastFrameTimestamp).ToList();
            if (frames.Count == 0)
            {
                return;
            }

            var joints = frames.Select(a => a.GetNearestSkeleton().Joints.FirstOrDefault(b => b.JointType == _joint)).ToList();
            Vector3 calculateDisplacementVector = CalculateDisplacement(joints);

            if (calculateDisplacementVector.Length > MinimalVectorLength)
            {
                LogString.Log("Event: MovementAnalyzer: " + calculateDisplacementVector.X + " " + calculateDisplacementVector.Y + " " + calculateDisplacementVector.Z);
                var duration = CalculateDuration(frames);
                Raise(()=>RaiseEvent(frames, calculateDisplacementVector, duration));
            }
        }
Exemple #6
0
        protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs)
        {
            if (!Configuration.swipeNavigation) return;

            var frames = _framesCollector.GetFrames(LastFrameTimestamp).ToList();
            if (frames.Count == 0)
            {
                return;
            }

            if (!EnsureDuration(frames))
            {
                return;
            }

            var joints = frames.Select(a => a.GetNearestSkeleton().Joints.First(j => j.JointType ==_joint)).ToList();

            // Swipe to right
            if (ScanPositions(joints, (p1, p2) => Math.Abs(p2.Y - p1.Y) < SwipeMaximalHeight, // Height
                (p1, p2) => p2.X - p1.X > -0.01f, // Progression to right
                (p1, p2) => Math.Abs(p2.X - p1.X) > SwipeMinimalLength))//Length
            {
                LogString.Log("Event: SwipeToRight");
                Raise(()=>RaiseGestureDetected(new SwipeEventArgs(GesturesEnum.SwipeToRight)));
                return;
            }

            // Swipe to left
            if (ScanPositions(joints, (p1, p2) => Math.Abs(p2.Y - p1.Y) < SwipeMaximalHeight,  // Height
                (p1, p2) => p2.X - p1.X < 0.01f, // Progression to right
                (p1, p2) => Math.Abs(p2.X - p1.X) > SwipeMinimalLength))// Length
            {
                LogString.Log("Event: SwipeToLeft");
                Raise(()=>RaiseGestureDetected(new SwipeEventArgs(GesturesEnum.SwipeToLeft)));
                return;
            }
        }
Exemple #7
0
        protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs)
        {
            if (!Configuration.postureNavigation) return;

            var frames =_framesCollector.GetFrames(LastFrameTimestamp).ToList();
            if (frames.Count == 0)
            {
                return;
            }

            Vector3? headPosition = null;
            Vector3? leftHandPosition = null;
            Vector3? rightHandPosition = null;

            var skeleton = frames.Last().GetNearestSkeleton();
            //foreach (Skeleton skeleton in frames.Select(a=>a.GetNearestSkeleton()))
            //{
            foreach (var joint in skeleton.Joints)
            {
                if (joint.TrackingState != TJointTrackingState.Tracked)
                    continue;

                switch (joint.JointType)
                {
                    case TJointType.Head:
                        headPosition = joint.Position.ToVector3();
                        break;
                    case TJointType.HandLeft:
                        leftHandPosition = joint.Position.ToVector3();
                        break;
                    case TJointType.HandRight:
                        rightHandPosition = joint.Position.ToVector3();
                        break;
                }
            }

            // HandsJoined
            if (CheckHandsJoined(rightHandPosition, leftHandPosition, headPosition))
            {
                handsJoined++;
                if (handsJoined == _postureFramesDuration)
                {
                    handsJoined = 0;
                    LogString.Log("Event: HandsJoined");
                    RaisePostureDetected(PosturesEnum.HandsJoined);
                }
            }

            // LeftHandOverHead
            if (CheckHandOverHead(headPosition, leftHandPosition))
            {
                leftHandOverHead++;
                if (leftHandOverHead == _postureFramesDuration)
                {
                    leftHandOverHead = 0;
                    LogString.Log("Event: LeftHandOverHead");
                    RaisePostureDetected(PosturesEnum.LeftHandOverHead);
                }
            }

            // RightHandOverHead
            if (CheckHandOverHead(headPosition, rightHandPosition))
            {
                rightHandOverHead++;
                if (rightHandOverHead == _postureFramesDuration)
                {
                    rightHandOverHead = 0;
                    LogString.Log("Event: RightHandOverHead");
                    RaisePostureDetected(PosturesEnum.RightHandOverHead);
                }
            }

            // LeftHello
            if (CheckHello(headPosition, leftHandPosition))
            {
                leftHello++;
                if (leftHello == _postureFramesDuration)
                {
                    leftHello = 0;
                    LogString.Log("Event: LeftHello");
                    RaisePostureDetected(PosturesEnum.LeftHello);
                }
            }

            // RightHello
            if (CheckHello(headPosition, rightHandPosition))
            {
                rightHello++;
                if (rightHello == _postureFramesDuration)
                {
                    rightHello = 0;
                    LogString.Log("Event: RightHello");
                    RaisePostureDetected(PosturesEnum.RightHello);
                }
            }
            //}
            _lastPosture = null;
        }
Exemple #8
0
 protected abstract void Analyze(FrameReadyEventArgs frameReadyEventArgs);