Update(dev): SwipeRightHand à la façont T pose

pull/22/head
Louis DUFOUR 1 year ago
parent eb52f7c786
commit 76ea8f36cc

@ -13,10 +13,10 @@ namespace MyGesturesBank
{
return new List<BaseGesture>
{
//new SwipeRightHand(),
//new PostureHandsOnHead(),
//new PostureHandUp(),
//new RightHandUp(),
new SwipeRightHand(),
new PostureHandsOnHead(),
new PostureHandUp(),
new RightHandUp(),
new ClapHands(),
// Ajoutez d'autres gestes ici
};

@ -11,6 +11,7 @@ namespace MyGesturesBank
public class SwipeRightHand : Gesture
{
private float previousX = float.NaN;
private bool gestureStarted = false;
protected override bool TestInitialConditions(Body body)
{
@ -18,7 +19,17 @@ namespace MyGesturesBank
var shoulderRight = body.Joints[JointType.ShoulderRight].Position;
// Conditions initiales : main droite au niveau ou à droite de l'épaule droite, mais pas trop éloignée
return handRight.X >= shoulderRight.X && handRight.X - shoulderRight.X < 0.5f;
bool initialCondition = handRight.X >= shoulderRight.X && handRight.X - shoulderRight.X < 0.4f;
if (initialCondition && !gestureStarted)
{
// Si les conditions initiales sont remplies et que le geste n'a pas encore commencé,
// initialiser previousX et marquer le geste comme commencé
previousX = handRight.X;
gestureStarted = true;
return false; // Attendre le prochain frame pour commencer l'évaluation
}
return initialCondition;
}
protected override bool TestPosture(Body body)
@ -32,6 +43,8 @@ namespace MyGesturesBank
protected override bool TestRunningGesture(Body body)
{
if (!gestureStarted) return false; // Assurer que le geste a commencé correctement
var handRight = body.Joints[JointType.HandRight].Position.X;
if (!float.IsNaN(previousX))
@ -52,7 +65,13 @@ namespace MyGesturesBank
var spineBase = body.Joints[JointType.SpineBase].Position;
// 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
if (handRight.X > spineBase.X + 0.8f) // Ajustez cette valeur selon le besoin
{
gestureStarted = false; // Réinitialiser l'état du geste
previousX = float.NaN; // Préparer pour la prochaine détection
return true;
}
return false;
}
public override string GestureName => "Swipe Right Hand";

Loading…
Cancel
Save