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;
// 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;
}
}
}

@ -9,23 +9,38 @@ 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 IsTesting { get; protected 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 mCurrentFrameCount = 0;
// public bool isRecognitionRunning { get; set; }
public override void TestGesture(Body body)
{
if (!IsTesting)
{
if (TestInitialConditions(body))
{
IsTesting = true;
mCurrentFrameCount = 0;
}
}
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 TestPosture(Body body);
abstract protected bool TestRunningGesture(Body body);

Loading…
Cancel
Save