protected override void Analyze(FrameReadyEventArgs frameReadyEventArgs) { if (!Configuration.movementNavigation) { return; } var frames = _framesCollector.GetFrames().ToList(); if (frames.Count == 0) { return; } var joints = frames.Select(a => a.GetNearestSkeleton().Joints.First(j => j.JointType == _joint)).ToList(); Vector3 calculateDisplacementVector = CalculateDisplacement(joints); if (calculateDisplacementVector.Length > MinimalVectorLength) { _oldDisplacementVector = calculateDisplacementVector; } var duration = CalculateDuration(frames); LogString.Log("Event: ContinousMovementAnalyzer: " + calculateDisplacementVector.X + " " + calculateDisplacementVector.Y + " " + calculateDisplacementVector.Z); Raise(() => RaiseEvent(frames, _oldDisplacementVector, duration)); }
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); } }
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; } }
private bool LeftHandActive(double diffLeft, TSkeletonPoint lastLeftHandFrame) { if (diffLeft > Configuration.activeHandDistance) { if (!leftHandActivated) { LogString.Log("LeftHand Activated"); LeftLastPosition = lastLeftHandFrame; leftHandActivated = true; ignoredCalls = Configuration.framesSkipped; } return(true); } else if (leftHandActivated) { LogString.Log("LeftHand Deactivated"); bothHandsActivated = false; leftHandActivated = false; } return(false); }
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)); } }
private void PostureAnalyzerOnPostureDetected(object sender, PostureEventArgs args) { switch (args.Posture) { case PosturesEnum.LeftHello: { PointLatLng pos; if (Marker != null) { pos = new PointLatLng(Marker.Position.Lat, Marker.Position.Lng); } else { pos = new PointLatLng(GMapControl.Position.Lat, GMapControl.Position.Lng); } GMapMarker flag = new GMapMarker(new PointLatLng()) { Position = pos, ZIndex = int.MaxValue }; flag.Shape = new CustomMarkerDemo(flag, "FLAG"); GMapControl.Markers.Add(flag); } break; case PosturesEnum.RightHandOverHead: { Configuration.maxHandLength = 0.4; Configuration.activeHandDistance = 0.25; LogString.Log("Restoring defaults"); } break; case PosturesEnum.LeftHandOverHead: { LogString.Log("LeftOverHead"); if (GMapControl.Markers.Any()) { var marker = GMapControl.Markers.Last(); marker.Shape = null; GMapControl.Markers.Remove(marker); } } break; case PosturesEnum.HandsJoined: { CursorMarkerExists = false; if (Marker != null) { GMapControl.Markers.Remove(Marker); Marker = null; //LogString.Log(Marker.ToString()); } if (GMapControl.Markers.Count == 0) { return; } var mRoute = new GMapMarker(GMapControl.Markers[0].Position); { mRoute.Route.AddRange(GMapControl.Markers.Select(a => new PointLatLng(a.Position.Lat - 100, a.Position.Lng))); var gMapControl = GMapControl.Markers[0].Map; mRoute.RegenerateRouteShape(gMapControl); mRoute.ZIndex = -1; } GMapControl.Markers.Add(mRoute); } break; } }
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; }