From 1ac8d06ad598fd876118e9d90735d3d9c88e0080 Mon Sep 17 00:00:00 2001 From: "johan.lachenal" Date: Wed, 7 Feb 2024 09:53:06 +0100 Subject: [PATCH] UPDATE(dev): add test in program --- Sources/ConsoleApp/Program.cs | 67 ++----------------- Sources/KinectUtils/AllGesturesFactory.cs | 22 ------ Sources/KinectUtils/GestureManager.cs | 1 + Sources/KinectUtils/KinectUtils.csproj | 1 - .../LibMyGesturesBank/AllGesturesFactory.cs | 6 +- .../LibMyGesturesBank/MyGesturesBank.csproj | 1 + 6 files changed, 12 insertions(+), 86 deletions(-) delete mode 100644 Sources/KinectUtils/AllGesturesFactory.cs diff --git a/Sources/ConsoleApp/Program.cs b/Sources/ConsoleApp/Program.cs index b8f5ea7..55f5346 100644 --- a/Sources/ConsoleApp/Program.cs +++ b/Sources/ConsoleApp/Program.cs @@ -1,4 +1,5 @@ -using Lib; +using KinectUtils; +using Lib; using Microsoft.Kinect; using MyGesturesBank; using System; @@ -16,68 +17,10 @@ namespace ConsoleApp { static void Main(string[] args) { + AllGesturesFactory allGesturesFactory = new AllGesturesFactory(); + GestureManager.AddGestures(allGesturesFactory); KinectManager kinectManager = new KinectManager(); - Canvas skeletonCanvas = null; - KinectStreamsFactory Factory = new KinectStreamsFactory(kinectManager, skeletonCanvas); - BodyImageStream CurrentKinectStream = (BodyImageStream)Factory[KinectStreams.Body]; - CurrentKinectStream.Start(); - PostureHandUp handUpPosture = new PostureHandUp(); - PostureHandsOnHead handsOnHeadPosture = new PostureHandsOnHead(); - handUpPosture.GestureRecognized += (sender, e) => - { - Console.WriteLine("Posture Hand Up reconnue !"); - }; - handsOnHeadPosture.GestureRecognized += (sender, e) => - { - Console.WriteLine("Posture Hands On Head reconnue !"); - }; - Body body = null; - while (true) - { - body = CurrentKinectStream.Bodies.FirstOrDefault(); - if (body != null) - { - handUpPosture.TestGesture(body); - handsOnHeadPosture.TestGesture(body); - } - Thread.Sleep(50); - } - // KinectManager kinectManager = new KinectManager(); - // if (kinectManager.StartSensor()) - // { - // Console.WriteLine("Kinect n'est pas connecté ou non reconnu."); - // return; - // } - - // // Créez les instances de vos postures - // PostureHandUp handUpPosture = new PostureHandUp(); - // PostureHandsOnHead handsOnHeadPosture = new PostureHandsOnHead(); - - // // Abonnez-vous aux événements de reconnaissance de posture - // handUpPosture.GestureRecognized += (sender, e) => - // { - // Console.WriteLine("Posture Hand Up reconnue !"); - // }; - - // handsOnHeadPosture.GestureRecognized += (sender, e) => - // { - // Console.WriteLine("Posture Hands On Head reconnue !"); - // }; - - // // Boucle pour tester les postures - // while (true) - // { - // Body body = kinecManager.GetNextBody(); // Méthode fictive pour obtenir les données du corps - // if (body != null) - // { - // handUpPosture.TestGesture(body); - // handsOnHeadPosture.TestGesture(body); - // } - - // Thread.Sleep(50); // Une petite pause pour ne pas surcharger le CPU - // } - //} - + GestureManager.StartAcquiringFrames(kinectManager); } } } diff --git a/Sources/KinectUtils/AllGesturesFactory.cs b/Sources/KinectUtils/AllGesturesFactory.cs deleted file mode 100644 index 7305108..0000000 --- a/Sources/KinectUtils/AllGesturesFactory.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using KinectUtils; - -namespace MyGesturesBank -{ - public class AllGesturesFactory : IGestureFactory - { - public IEnumerable CreateGestures() - { - return new List - { - //new SwipeRightHand(), - //new ClapHands() - // Ajoutez d'autres gestes ici - }; - } - } -} diff --git a/Sources/KinectUtils/GestureManager.cs b/Sources/KinectUtils/GestureManager.cs index cece5c1..0708df7 100644 --- a/Sources/KinectUtils/GestureManager.cs +++ b/Sources/KinectUtils/GestureManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Runtime.Remoting.Messaging; using System.Text; using System.Threading.Tasks; diff --git a/Sources/KinectUtils/KinectUtils.csproj b/Sources/KinectUtils/KinectUtils.csproj index c64f282..fa4c521 100644 --- a/Sources/KinectUtils/KinectUtils.csproj +++ b/Sources/KinectUtils/KinectUtils.csproj @@ -42,7 +42,6 @@ - diff --git a/Sources/LibMyGesturesBank/AllGesturesFactory.cs b/Sources/LibMyGesturesBank/AllGesturesFactory.cs index 8b62daa..0df7c54 100644 --- a/Sources/LibMyGesturesBank/AllGesturesFactory.cs +++ b/Sources/LibMyGesturesBank/AllGesturesFactory.cs @@ -14,7 +14,11 @@ namespace MyGesturesBank return new List { new SwipeRightHand(), - //new ClapHands() + new PostureHandsOnHead(), + new PostureHandUp(), + new RightHandUp(), + new SwipeRightHand(), + new TwoHandsDragon(), // Ajoutez d'autres gestes ici }; } diff --git a/Sources/LibMyGesturesBank/MyGesturesBank.csproj b/Sources/LibMyGesturesBank/MyGesturesBank.csproj index 562b0da..1cd793f 100644 --- a/Sources/LibMyGesturesBank/MyGesturesBank.csproj +++ b/Sources/LibMyGesturesBank/MyGesturesBank.csproj @@ -44,6 +44,7 @@ +