Health/Assets/Scripts/PoseCheck/HeadTurnLeft.cs

45 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 (!"Nose".IsValid(points) || "LEar".IsValid(points) || "Neck".IsValid(points)) // 必须包含 Nose 和 LEar 和 Neck 的点位
return false;
var basePoint = YogaManager.Instance.Points;
//左转头检测
//当 LShoulder 和 RShoulder 都未检测到时
if (!"LShoulder".IsValid(points) || !"RShoulder".IsValid(points))
{
}
//当 LShoulder 和 RShoulder 都检测到时,以 LShoulder 和 RShoulder 为基准
//
if ("LEar".IsValid(points) && !"REar".IsValid(points))
{
return true;
}
if (Math.Abs("LEar".p(points).x - "Nose".p(points).x) > Math.Abs("REar".p(points).x - "Nose".p(points).x))
{
return true;
}
return false;
}
}