|
|
@ -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";
|
|
|
|