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> return new List<BaseGesture>
{ {
//new SwipeRightHand(), new SwipeRightHand(),
//new PostureHandsOnHead(), new PostureHandsOnHead(),
//new PostureHandUp(), new PostureHandUp(),
//new RightHandUp(), new RightHandUp(),
new ClapHands(), new ClapHands(),
// Ajoutez d'autres gestes ici // Ajoutez d'autres gestes ici
}; };

@ -11,6 +11,7 @@ namespace MyGesturesBank
public class SwipeRightHand : Gesture public class SwipeRightHand : Gesture
{ {
private float previousX = float.NaN; private float previousX = float.NaN;
private bool gestureStarted = false;
protected override bool TestInitialConditions(Body body) protected override bool TestInitialConditions(Body body)
{ {
@ -18,7 +19,17 @@ namespace MyGesturesBank
var shoulderRight = body.Joints[JointType.ShoulderRight].Position; var shoulderRight = body.Joints[JointType.ShoulderRight].Position;
// Conditions initiales : main droite au niveau ou à droite de l'épaule droite, mais pas trop éloignée // 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) protected override bool TestPosture(Body body)
@ -32,6 +43,8 @@ namespace MyGesturesBank
protected override bool TestRunningGesture(Body body) 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; var handRight = body.Joints[JointType.HandRight].Position.X;
if (!float.IsNaN(previousX)) if (!float.IsNaN(previousX))
@ -52,7 +65,13 @@ namespace MyGesturesBank
var spineBase = body.Joints[JointType.SpineBase].Position; var spineBase = body.Joints[JointType.SpineBase].Position;
// Condition de fin : la main droite est bien à droite de la base de la colonne vertébrale // 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"; public override string GestureName => "Swipe Right Hand";

Loading…
Cancel
Save