diff --git a/Sources/ConsoleApp/Program.cs b/Sources/ConsoleApp/Program.cs index 55f5346..ccf4e43 100644 --- a/Sources/ConsoleApp/Program.cs +++ b/Sources/ConsoleApp/Program.cs @@ -17,10 +17,18 @@ namespace ConsoleApp { static void Main(string[] args) { + // allumer la kinect + KinectManager kinectManager = new KinectManager(); + kinectManager.StartSensor(); + Console.WriteLine("Kinect démarre"); + AllGesturesFactory allGesturesFactory = new AllGesturesFactory(); GestureManager.AddGestures(allGesturesFactory); - KinectManager kinectManager = new KinectManager(); GestureManager.StartAcquiringFrames(kinectManager); + while (true) + { + //Thread.Sleep(50); + } } } } diff --git a/Sources/KinectUtils/GestureManager.cs b/Sources/KinectUtils/GestureManager.cs index 0708df7..1831e27 100644 --- a/Sources/KinectUtils/GestureManager.cs +++ b/Sources/KinectUtils/GestureManager.cs @@ -20,11 +20,7 @@ namespace KinectUtils public static void AddGestures(IGestureFactory factory) { - var gestures = factory.CreateGestures(); - foreach (var gesture in gestures) - { - AddGesture(gesture); - } + KnownGestures = (List)factory.CreateGestures(); } public static void AddGesture(BaseGesture gesture) { @@ -55,14 +51,23 @@ namespace KinectUtils { if (bodyframe != null) { - bodyframe.GetAndRefreshBodyData(bodies); - foreach (var body in bodies) + + if(bodies == null) { - if (body.IsTracked) + bodies = new Body[bodyframe.BodyCount]; + } + bodyframe.GetAndRefreshBodyData(bodies); + if (bodies != null) { - foreach(var gesture in KnownGestures) + foreach (var body in bodies) { - gesture.TestGesture(body); + if (body.IsTracked) + { + foreach (var gesture in KnownGestures) + { + gesture.TestGesture(body); + } + } } } } @@ -70,4 +75,3 @@ namespace KinectUtils } } } -} diff --git a/Sources/LibMyGesturesBank/ClapHands.cs b/Sources/LibMyGesturesBank/ClapHands.cs index c1b6e81..dc01856 100644 --- a/Sources/LibMyGesturesBank/ClapHands.cs +++ b/Sources/LibMyGesturesBank/ClapHands.cs @@ -39,6 +39,7 @@ namespace LibMyGesturesBank // Le clap est un geste instantané, donc si les conditions sont remplies une fois, le geste est considéré comme terminé return true; } + public override string GestureName => "Clap Hands"; } } diff --git a/Sources/LibMyGesturesBank/PostureHandUp.cs b/Sources/LibMyGesturesBank/PostureHandUp.cs index 38f5861..661249b 100644 --- a/Sources/LibMyGesturesBank/PostureHandUp.cs +++ b/Sources/LibMyGesturesBank/PostureHandUp.cs @@ -13,6 +13,7 @@ namespace MyGesturesBank return handRight.Y > head.Y || handLeft.Y > head.Y; } + public override string GestureName => "Posture Hand Up"; } diff --git a/Sources/LibMyGesturesBank/PostureHandsOnHead .cs b/Sources/LibMyGesturesBank/PostureHandsOnHead .cs index 239eee1..a1835f2 100644 --- a/Sources/LibMyGesturesBank/PostureHandsOnHead .cs +++ b/Sources/LibMyGesturesBank/PostureHandsOnHead .cs @@ -17,6 +17,7 @@ namespace MyGesturesBank return Math.Abs(handRight.Y - head.Y) < threshold && Math.Abs(handLeft.Y - head.Y) < threshold; } + public override string GestureName => "Posture Hands On Head"; } diff --git a/Sources/LibMyGesturesBank/RightHandUp.cs b/Sources/LibMyGesturesBank/RightHandUp.cs index 8de2ef5..3d8c90b 100644 --- a/Sources/LibMyGesturesBank/RightHandUp.cs +++ b/Sources/LibMyGesturesBank/RightHandUp.cs @@ -17,6 +17,7 @@ namespace MyGesturesBank return handRight.Y > head.Y; } + public override string GestureName => "Right Hand Up"; } } diff --git a/Sources/LibMyGesturesBank/SwipeRightHand.cs b/Sources/LibMyGesturesBank/SwipeRightHand.cs index c4c8eeb..44291b0 100644 --- a/Sources/LibMyGesturesBank/SwipeRightHand.cs +++ b/Sources/LibMyGesturesBank/SwipeRightHand.cs @@ -55,6 +55,7 @@ namespace MyGesturesBank // Condition de fin : la main droite est bien à droite de la base de la colonne vertébrale return handRight.X > spineBase.X + 0.5f; // Ajustez cette valeur selon le besoin } + public override string GestureName => "Swipe Right Hand"; } } diff --git a/Sources/LibMyGesturesBank/TwoHandsDragon.cs b/Sources/LibMyGesturesBank/TwoHandsDragon.cs index db3a161..6b5400a 100644 --- a/Sources/LibMyGesturesBank/TwoHandsDragon.cs +++ b/Sources/LibMyGesturesBank/TwoHandsDragon.cs @@ -18,6 +18,7 @@ namespace MyGesturesBank return handRight.Y > head.Y && handLeft.Y > head.Y; } + public override string GestureName => "Two Hands Dragon"; } }