Add(dev): testgesture and basegesture

pull/18/head
Louis DUFOUR 1 year ago
parent 9b02f6eb31
commit 083f08a901

@ -9,17 +9,28 @@ namespace KinectUtils
public event EventHandler GestureRecognized; public event EventHandler GestureRecognized;
// Nom du geste - marqué comme virtual pour permettre la substitution // 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 // Méthode abstraite pour tester le geste
public abstract void TestGesture(Body body); public abstract void TestGesture(Body body);
// Méthode protégée pour déclencher l'événement GestureRecognized // 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;
}
}
} }

@ -9,23 +9,38 @@ namespace KinectUtils
{ {
abstract class Gesture : BaseGesture abstract class Gesture : BaseGesture
{ {
protected int _maxNbOfFrames; public bool IsTesting { get; protected set; }
protected int _minNbOfFrames; protected int MinNbOfFrames = 10; // Exemple de valeur, ajustez selon le geste
private int currentFrameCount; protected int MaxNbOfFrames = 50; // Exemple de valeur, ajustez selon le geste
public bool isRecognitionRunning { get; set; } private int mCurrentFrameCount = 0;
public int MinNbOfFrames { // public bool isRecognitionRunning { get; set; }
get { return _minNbOfFrames; }
private set { _minNbOfFrames = value; } public override void TestGesture(Body body)
} {
public int MaxNbOfFrames if (!IsTesting)
{ {
get { return _maxNbOfFrames; } if (TestInitialConditions(body))
private set { _maxNbOfFrames = value; } {
IsTesting = true;
mCurrentFrameCount = 0;
} }
public override void TestGesture(Body body) }
else
{ {
mCurrentFrameCount++;
if (!TestPosture(body) || !TestRunningGesture(body) || mCurrentFrameCount > MaxNbOfFrames)
{
IsTesting = false;
}
else if (TestEndConditions(body) && mCurrentFrameCount >= MinNbOfFrames)
{
OnGestureRecognized(body);
IsTesting = false;
} }
}
}
abstract protected bool TestInitialConditions(Body body); abstract protected bool TestInitialConditions(Body body);
abstract protected bool TestPosture(Body body); abstract protected bool TestPosture(Body body);
abstract protected bool TestRunningGesture(Body body); abstract protected bool TestRunningGesture(Body body);

Loading…
Cancel
Save