You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.0 KiB

using KinectUtils;
using Microsoft.Kinect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyGesturesBank
{
public class SwipeRightHand : Gesture
{
private float previousX = float.NaN;
protected override bool TestInitialConditions(Body body)
{
var handRight = body.Joints[JointType.HandRight].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
return handRight.X >= shoulderRight.X && handRight.X - shoulderRight.X < 0.5f;
}
protected override bool TestPosture(Body body)
{
var handRight = body.Joints[JointType.HandRight].Position;
var head = body.Joints[JointType.Head].Position;
// La main droite ne doit pas être plus haute que la tête
return handRight.Y <= head.Y;
}
protected override bool TestRunningGesture(Body body)
{
var handRight = body.Joints[JointType.HandRight].Position.X;
if (!float.IsNaN(previousX))
{
// Vérifie si la main droite se déplace vers la droite
bool isMovingRight = handRight > previousX;
previousX = handRight;
return isMovingRight;
}
previousX = handRight;
return false;
}
protected override bool TestEndConditions(Body body)
{
var handRight = body.Joints[JointType.HandRight].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
return handRight.X > spineBase.X + 0.5f; // Ajustez cette valeur selon le besoin
}
public override string GestureName => "Swipe Right Hand";
}
}