Health/Assets/Scripts/PoseCheck/HeadTurnLeft.cs

44 lines
1.1 KiB
C#

using OpenCVForUnity.CoreModule;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HeadTurnLeft : PoseBase
{
private bool _isRunning = false;
public override bool CheckPose(List<Point> points)
{
if (!CheckPoint(points, "Nose") || CheckPoint(points, "LEar") || CheckPoint(points, "Neck")) // 必须包含 Nose 和 LEar 和 Neck 的点位
return false;
//左转头检测
//当 LShoulder 和 RShoulder 都未检测到时
if (!CheckPoint(points, "LShoulder") || !CheckPoint(points, "RShoulder"))
{
}
//当 LShoulder 和 RShoulder 都检测到时,以 LShoulder 和 RShoulder 为基准
//
if (CheckPoint(points, "LEar") && !CheckPoint(points, "REar"))
{
return true;
}
if (Math.Abs(points[YogaConfig.BODY_PARTS["LEar"]].x - points[YogaConfig.BODY_PARTS["Nose"]].x) > Math.Abs(points[YogaConfig.BODY_PARTS["REar"]].x - points[YogaConfig.BODY_PARTS["Nose"]].x))
{
return true;
}
return false;
}
}