diff --git a/Sources/KinectUtils/BaseGesture.cs b/Sources/KinectUtils/BaseGesture.cs
index c12223a..c414db6 100644
--- a/Sources/KinectUtils/BaseGesture.cs
+++ b/Sources/KinectUtils/BaseGesture.cs
@@ -9,17 +9,28 @@ namespace KinectUtils
public event EventHandler GestureRecognized;
// Nom du geste - marqué comme virtual pour permettre la substitution
- public virtual string GestureName { get; protected set; }
+ public string GestureName { get; protected set; }
// Méthode abstraite pour tester le geste
public abstract void TestGesture(Body body);
// Méthode protégée pour déclencher l'événement GestureRecognized
- protected virtual void OnGestureRecognized()
+ protected virtual void OnGestureRecognized(Body body)
{
- GestureRecognized?.Invoke(this, EventArgs.Empty);
+ GestureRecognized?.Invoke(this, new GestureRecognizedEventArgs(body, GestureName));
}
}
+ public class GestureRecognizedEventArgs : EventArgs
+ {
+ public Body Body { get; private set; }
+ public string GestureName { get; private set; }
+
+ public GestureRecognizedEventArgs(Body body, string gestureName)
+ {
+ Body = body;
+ GestureName = gestureName;
+ }
+ }
}
diff --git a/Sources/KinectUtils/Gesture.cs b/Sources/KinectUtils/Gesture.cs
index 42dd8ad..b05249e 100644
--- a/Sources/KinectUtils/Gesture.cs
+++ b/Sources/KinectUtils/Gesture.cs
@@ -9,29 +9,42 @@ namespace KinectUtils
{
abstract class Gesture : BaseGesture
{
- protected int _maxNbOfFrames;
- protected int _minNbOfFrames;
- private int currentFrameCount;
- public bool isRecognitionRunning { get; set; }
- public int MinNbOfFrames {
- get { return _minNbOfFrames; }
- private set { _minNbOfFrames = value; }
- }
- public int MaxNbOfFrames
- {
- get { return _maxNbOfFrames; }
- private set { _maxNbOfFrames = value; }
- }
- public bool TestGesture(Body body)
+ public bool IsRecognitionRunning { get; set; }
+
+ protected int MinNbOfFrames = 10; // Exemple de valeur, ajustez selon le geste
+ protected int MaxNbOfFrames = 50; // Exemple de valeur, ajustez selon le geste
+ private int currentFrameCount = 0;
+
+ public override void TestGesture(Body body)
{
- TestInitialConditions(body);
- TestPosture(body);
- TestRunningGesture(body);
- TestEndConditions(body);
+ if (!IsRecognitionRunning)
+ {
+ if (TestInitialConditions(body))
+ {
+ IsRecognitionRunning = true;
+ currentFrameCount = 0;
+ }
+ }
+ else
+ {
+ currentFrameCount++;
+
+ if (!TestPosture(body) || !TestRunningGesture(body) || currentFrameCount > MaxNbOfFrames)
+ {
+ IsRecognitionRunning = false;
+ }
+ else if (TestEndConditions(body) && currentFrameCount >= MinNbOfFrames)
+ {
+ OnGestureRecognized(body);
+ IsRecognitionRunning = false;
+ }
+ }
}
+
abstract protected bool TestInitialConditions(Body body);
abstract protected bool TestPosture(Body body);
abstract protected bool TestRunningGesture(Body body);
abstract protected bool TestEndConditions(Body body);
}
}
+
diff --git a/Sources/WpfApp/MainWindow.xaml b/Sources/WpfApp/MainWindow.xaml
index dd3f6fb..4e345b9 100644
--- a/Sources/WpfApp/MainWindow.xaml
+++ b/Sources/WpfApp/MainWindow.xaml
@@ -19,11 +19,11 @@
-
-
-
-
-
+
+
+
+
+