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.

38 lines
1.2 KiB

using Microsoft.Kinect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyGesturesBank
{
public class PostureHandsOnHead : Posture
{
protected override bool TestPosture(Body body)
{
// Condition pour la main droite proche de la tête
bool rightHandNearHead = IsHandNearHead(body.Joints[JointType.HandRight], body.Joints[JointType.Head]);
// Condition pour la main gauche proche de la tête
bool leftHandNearHead = IsHandNearHead(body.Joints[JointType.HandLeft], body.Joints[JointType.Head]);
return rightHandNearHead && leftHandNearHead;
}
private bool IsHandNearHead(Joint hand, Joint head)
{
// Exemple de condition : la main est à moins de 30 cm de la tête
return Math.Sqrt(
Math.Pow(hand.Position.X - head.Position.X, 2) +
Math.Pow(hand.Position.Y - head.Position.Y, 2) +
Math.Pow(hand.Position.Z - head.Position.Z, 2)) < 0.3;
}
public override string GestureName => "Hands On Head";
}
}