# HG changeset patch # User PAMPHILE Jonathan # Date 1257526240 -3600 # Node ID b37888f59cf2dc5a6f8f68cdd21d8fe70b13e6e5 # Parent e642ad0c366bb99c8718d86202589b6c0b423bf2 Gesture diff -r e642ad0c366b -r b37888f59cf2 src/FingersDance.Control.Player/UserControlPlayer.xaml.cs --- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Thu Nov 05 22:40:36 2009 +0100 +++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Fri Nov 06 17:50:40 2009 +0100 @@ -121,18 +121,61 @@ Console.WriteLine("gesture detected: " + e.Gesture); switch (e.Gesture) { - case "UP": - // - usercontrolInfoUser.LabelSession.Content = "UP!"; + case "TRIGGER": + + usercontrolInfoUser.LabelSession.Content = "TRIGGER!"; + break; + case "CONTRE POINTS": + + usercontrolInfoUser.LabelSession.Content = "CONTRE POINTS!"; + break; + case "CONTRE PESANTEUR": + + usercontrolInfoUser.LabelSession.Content = "CONTRE PESANTEUR!"; + break; + case "AVEC PESANTEUR": + + usercontrolInfoUser.LabelSession.Content = "AVEC PESANTEUR!"; + break; + case "ALIGNEMENT": + + usercontrolInfoUser.LabelSession.Content = "ALIGNEMENT!"; + break; + case "CONTACT VISUEL": + + usercontrolInfoUser.LabelSession.Content = "CONTACT VISUEL!"; + break; + case "MOUVEMENT CONTRAINTE": + + usercontrolInfoUser.LabelSession.Content = "MOUVEMENT CONTRAINTE!"; break; - case "LEFT": - usercontrolInfoUser.LabelSession.Content = "LEFT!"; + case "UN DANSEUR": + + usercontrolInfoUser.LabelSession.Content = "UN DANSEUR!"; + break; + case "DEUX DANSEURS": + + usercontrolInfoUser.LabelSession.Content = "DEUX DANSEURS!"; + break; + case "TROIS DANSEURS": + + usercontrolInfoUser.LabelSession.Content = "TROIS DANSEURS!"; break; - case "RIGHT": - usercontrolInfoUser.LabelSession.Content = "RIGHT!"; + case "QUATRE DANSEURS": + + usercontrolInfoUser.LabelSession.Content = "QUATRE DANSEURS!"; + break; + case "TOUS LES DANSEURS": + + usercontrolInfoUser.LabelSession.Content = "TOUS LES DANSEURS!"; break; - case "DOWN": - usercontrolInfoUser.LabelSession.Content = "DOWN!"; + case "CONTACT TABLE/DANSEUR": + + usercontrolInfoUser.LabelSession.Content = "CONTACT TABLE/DANSEUR!"; + break; + case "PLAY-PAUSE": + usercontrolInfoUser.LabelSession.Content = "PLAY-PAUSE!"; + ButtonPlayPause_ContactDown(null, null); break; default: //this.TxtGesture.Text = e.Gesture; diff -r e642ad0c366b -r b37888f59cf2 src/FingersDance.GestureControl/GestureControl.cs --- a/src/FingersDance.GestureControl/GestureControl.cs Thu Nov 05 22:40:36 2009 +0100 +++ b/src/FingersDance.GestureControl/GestureControl.cs Fri Nov 06 17:50:40 2009 +0100 @@ -135,7 +135,7 @@ StylusPointCollection tmp2 = s.GetBezierStylusPoints(); // Generate a list of SurfaceGesturePoint, just X and Y but can be improve List pointList = new List(); - foreach (StylusPoint p in tmp2) + foreach (StylusPoint p in s.StylusPoints) pointList.Add(new SurfaceGesturePoint { X = p.X, Y = p.Y }); // create the gesture analyser and set the list SurfaceGesture gesture = new SurfaceGesture(pointList, 1); @@ -168,10 +168,9 @@ } #region Pattern - /// + /// /// return a String with the recognized pattern, "None" if no pattern /// - /// public String GetPattern(List gestures) { int found = 0; @@ -200,7 +199,6 @@ return p.Name; } } - return "None"; } @@ -262,18 +260,21 @@ case "Right": p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.RIGHT }); break; - case "DownRight": + case "Downright": p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.DOWNRIGHT }); break; - case "DownLeft": + case "Downleft": p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.DOWNLEFT }); break; - case "UpRight": + case "Upright": p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.UPRIGHT }); break; - case "UpLeft": + case "Upleft": p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.UPLEFT }); break; + case "TAP": + p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.TAP }); + break; default: break; } diff -r e642ad0c366b -r b37888f59cf2 src/FingersDance.GestureControl/GestureVector.cs --- a/src/FingersDance.GestureControl/GestureVector.cs Thu Nov 05 22:40:36 2009 +0100 +++ b/src/FingersDance.GestureControl/GestureVector.cs Fri Nov 06 17:50:40 2009 +0100 @@ -93,7 +93,7 @@ /*if (this.GetPattern() != "None") return true; else*/ - return false; + return false; } /// /// Get distance between two points @@ -125,155 +125,64 @@ /// private void Generate(List list) { + this.Clear(); if (list.Count < 2) { this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 }); return; } - SurfaceGestureVectorDirection lastDirection = SurfaceGestureVectorDirection.NONE; - int lastPoint = 0; - SurfaceGesturePoint LastChange = list[0]; - /////// TEST/////////// - if (this.GenerateCourb(list, 5) == true) - return; - this.Clear(); - /////////////////////// - - for (int i = 0; i < list.Count - 1; i++) + List Points = new List(); + List Vectors = new List(); + + for (int index = 1; index <= list.Count; index++) { - if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UP && lastDirection != SurfaceGestureVectorDirection.UP) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UP; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWN && lastDirection != SurfaceGestureVectorDirection.DOWN) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWN; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPLEFT; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPRIGHT; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNLEFT; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT) + if (index == list.Count / 2 || index == list.Count) { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.LEFT && lastDirection != SurfaceGestureVectorDirection.LEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.LEFT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.RIGHT && lastDirection != SurfaceGestureVectorDirection.RIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.RIGHT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPLEFT; + SurfaceGestureVector verctorTemp = AnalysePoints(Points); + if (Vectors.Count == 0 || !Vectors[Vectors.Count - 1].Direction.Equals(verctorTemp.Direction)) + Vectors.Add(verctorTemp); + Points.Clear(); } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPRIGHT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNLEFT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)) }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT; - } - ++lastPoint; + else + Points.Add(list[index]); } - Analyse(list); + foreach (SurfaceGestureVector elt in Vectors) + this.Add(elt); } - private void Analyse(List list) + SurfaceGestureVector AnalysePoints(List list) { - // Analyse de la forme - - double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; - foreach (SurfaceGestureVector elt in this) - { - switch (elt.Direction) - { - case SurfaceGestureVectorDirection.DOWN: - down += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNLEFT: - downleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNRIGHT: - downright += elt.Lenght; - break; - case SurfaceGestureVectorDirection.LEFT: - left += elt.Lenght; - break; - case SurfaceGestureVectorDirection.RIGHT: - right += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UP: - up += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPLEFT: - upleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPRIGHT: - upright += elt.Lenght; - break; - } - } - double diffX = Math.Abs(list[0].X - list[list.Count - 1].X); double diffY = Math.Abs(list[0].Y - list[list.Count - 1].Y); - if (diffX < 5) + if (diffX < 10 && diffY > 10) { - this.Clear(); - if (up > down) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up }); + if (list[0].Y > list[list.Count - 1].Y) + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = 0, Origin = list[0] }); else - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down }); + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = 0, Origin = list[0] }); + } + else if (diffY < 10 && diffX > 10) + { + if (list[list.Count - 1].X > list[0].X) + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = 0, Origin = list[0] }); + else + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = 0, Origin = list[0] }); } - else if (diffY < 5) + else if (diffX > 10 && diffY > 10) { - this.Clear(); - if (left > right) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left }); + if (list[0].Y > list[list.Count - 1].Y && list[list.Count - 1].X > list[0].X) + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = 0, Origin = list[0] }; + else if (list[0].Y > list[list.Count - 1].Y && list[list.Count - 1].X < list[0].X) + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = 0, Origin = list[0] }; + else if (list[0].Y < list[list.Count - 1].Y && list[list.Count - 1].X > list[0].X) + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = 0, Origin = list[0] }; else - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right }); + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = 0, Origin = list[0] }; } + else + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 }; } private SurfaceGestureVectorDirection GetHorizontal(SurfaceGesturePoint p1, SurfaceGesturePoint p2) @@ -281,41 +190,21 @@ if (p1.Y < p2.Y) { // go up - if (Math.Abs(p2.Y - p1.Y) > this.Precision) + if (Math.Abs(p2.X - p1.X) < Math.Abs(p2.Y - p1.Y)) + return SurfaceGestureVectorDirection.DOWN; + else { - if (Math.Abs(p2.X - p1.X) < Math.Abs(p2.Y - p1.Y)) - return SurfaceGestureVectorDirection.DOWN; + if (p1.X < p2.X) + return SurfaceGestureVectorDirection.DOWNRIGHT; else - { - if (p1.X < p2.X) - return SurfaceGestureVectorDirection.DOWNRIGHT; - else - return SurfaceGestureVectorDirection.DOWNLEFT; - } + return SurfaceGestureVectorDirection.DOWNLEFT; } - else - { - if (p1.X < p2.X) - return SurfaceGestureVectorDirection.DOWNRIGHT; - else - return SurfaceGestureVectorDirection.DOWNLEFT; - } } else { // go down - if (Math.Abs(p1.Y - p2.Y) > this.Precision) - { - if (Math.Abs(p1.X - p2.X) < Math.Abs(p1.Y - p2.Y)) - return SurfaceGestureVectorDirection.UP; - else - { - if (p1.X < p2.X) - return SurfaceGestureVectorDirection.UPRIGHT; - else - return SurfaceGestureVectorDirection.UPLEFT; - } - } + if (Math.Abs(p1.X - p2.X) < Math.Abs(p1.Y - p2.Y)) + return SurfaceGestureVectorDirection.UP; else { if (p1.X < p2.X) @@ -324,25 +213,15 @@ return SurfaceGestureVectorDirection.UPLEFT; } } - return SurfaceGestureVectorDirection.NONE; } + private SurfaceGestureVectorDirection GetVertical(SurfaceGesturePoint p1, SurfaceGesturePoint p2) { if (p1.X < p2.X) { // go left - if (Math.Abs(p2.X - p1.X) > this.Precision) - { - if (Math.Abs(p2.Y - p1.Y) < Math.Abs(p2.X - p1.X)) - return SurfaceGestureVectorDirection.RIGHT; - else - { - if (p1.Y < p2.Y) - return SurfaceGestureVectorDirection.DOWNRIGHT; - else - return SurfaceGestureVectorDirection.UPRIGHT; - } - } + if (Math.Abs(p2.Y - p1.Y) < Math.Abs(p2.X - p1.X)) + return SurfaceGestureVectorDirection.RIGHT; else { if (p1.Y < p2.Y) @@ -353,19 +232,9 @@ } else { - // go right - if (Math.Abs(p1.X - p2.X) > this.Precision) - { - if (Math.Abs(p1.Y - p2.Y) < Math.Abs(p1.X - p2.X)) - return SurfaceGestureVectorDirection.LEFT; - else - { - if (p1.Y < p2.Y) - return SurfaceGestureVectorDirection.DOWNLEFT; - else - return SurfaceGestureVectorDirection.UPLEFT; - } - } + // go right= + if (Math.Abs(p1.Y - p2.Y) < Math.Abs(p1.X - p2.X)) + return SurfaceGestureVectorDirection.LEFT; else { if (p1.Y < p2.Y) @@ -374,8 +243,8 @@ return SurfaceGestureVectorDirection.UPLEFT; } } - return SurfaceGestureVectorDirection.NONE; } + #endregion #region Override diff -r e642ad0c366b -r b37888f59cf2 src/FingersDance.GestureControl/Resources/Patterns.xml --- a/src/FingersDance.GestureControl/Resources/Patterns.xml Thu Nov 05 22:40:36 2009 +0100 +++ b/src/FingersDance.GestureControl/Resources/Patterns.xml Fri Nov 06 17:50:40 2009 +0100 @@ -1,37 +1,78 @@  + - UP + TRIGGER - UP + RIGHT - Up + Right + + + + TAP + + TAP + - LEFT + CONTRE POINTS - Up + TAP - Up + TAP - Up + TAP - Up + TAP + - RIGHT + CONTRE PESANTEUR + + + UPRIGHT-DOWNRIGHT + + Upright + Downright + + + + + + + AVEC PESANTEUR + DOWNRIGHT-UPRIGHT + + Downright + Upright + + + + + + + ALIGNEMENT + + + RIGHT + + Right + + + RIGHT Right @@ -39,4 +80,212 @@ + + + CONTACT VISUEL + + + DOWNRIGHT-DOWNLEFT + + Downright + Downleft + + + + DOWNLEFT-DOWNRIGHT + + Downleft + Downright + + + + + + + MOUVEMENT CONTRAINTE + + + DOWNLEFT-DOWNRIGHT + + Downleft + Downright + + + + DOWNRIGHT-DOWNLEFT + + Downright + Downleft + + + + + + + UN DANSEUR + + + DOWN + + Down + + + + + + + DEUX DANSEURS + + + DOWN + + Down + + + + DOWN + + Down + + + + + + + TROIS DANSEURS + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + + + + QUATRE DANSEURS + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + + + + TOUS LES DANSEURS + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + + + + CONTACT TABLE/DANSEUR + + + DOWNRIGHT + + Downright + + + + DOWNLEFT + + Downleft + + + + + + CONTACT TABLE-DANSEUR + + + DOWNLEFT + + Downleft + + + + DOWNRIGHT + + Downright + + + + + + + PLAY-PAUSE + + + TAP + + TAP + + + + + \ No newline at end of file diff -r e642ad0c366b -r b37888f59cf2 src/FingersDance.GestureControl/SurfaceGestureVector.cs --- a/src/FingersDance.GestureControl/SurfaceGestureVector.cs Thu Nov 05 22:40:36 2009 +0100 +++ b/src/FingersDance.GestureControl/SurfaceGestureVector.cs Fri Nov 06 17:50:40 2009 +0100 @@ -12,5 +12,6 @@ { public SurfaceGestureVectorDirection Direction { get; set; } public Double Lenght { get; set; } + public SurfaceGesturePoint Origin { get; set; } } } diff -r e642ad0c366b -r b37888f59cf2 src/FingersDance.GestureControl/SurfaceGestureVectorDirection.cs --- a/src/FingersDance.GestureControl/SurfaceGestureVectorDirection.cs Thu Nov 05 22:40:36 2009 +0100 +++ b/src/FingersDance.GestureControl/SurfaceGestureVectorDirection.cs Fri Nov 06 17:50:40 2009 +0100 @@ -18,7 +18,7 @@ UPRIGHT, DOWNLEFT, DOWNRIGHT, + TAP, NONE, - TAP, } } diff -r e642ad0c366b -r b37888f59cf2 src/FingersDance/Resources/menu.xml --- a/src/FingersDance/Resources/menu.xml Thu Nov 05 22:40:36 2009 +0100 +++ b/src/FingersDance/Resources/menu.xml Fri Nov 06 17:50:40 2009 +0100 @@ -153,6 +153,12 @@ ActionStartOrEndAnnotation + Choutes avec la pesanteur + + FingersDanceAnnotationButtonNiveau4 + ActionStartOrEndAnnotation + + Alignements FingersDanceAnnotationButtonNiveau4