using OpenCVForUnity.CoreModule; using OpenCVForUnity.ImgprocModule; using System; using System.Collections.Generic; using UnityEngine; public abstract class PoseBase { public abstract bool CheckPose(List points); public Dictionary GetVaildPoints(List points, List pointName) { var retVal = new Dictionary(); foreach (var name in pointName) { if (points[YogaConfig.BODY_PARTS[name]] != new Point(-1, -1)) { retVal.Add(name, points[YogaConfig.BODY_PARTS[name]]); } } return retVal; } public bool CheckPoint(List points, string partName) { var point = points[YogaConfig.BODY_PARTS[partName]]; if (point == new Point(-1, -1)) { //Debug.Log($"{partName}不在画面中"); return false; } return true; } //motion check public bool CheckMotion(List points, string partName, double threshold) { var point = points[YogaConfig.BODY_PARTS[partName]]; if (point == new Point(-1, -1)) { //Debug.Log($"{partName}不在画面中"); return false; } var lastPoint = YogaManager.Instance.Points[YogaConfig.BODY_PARTS[partName]]; if (lastPoint == new Point(-1, -1)) { YogaManager.Instance.Points[YogaConfig.BODY_PARTS[partName]] = point; return false; } var distance = Math.Sqrt(Math.Pow(point.x - lastPoint.x, 2) + Math.Pow(point.y - lastPoint.y, 2)); if (distance > threshold) { YogaManager.Instance.Points[YogaConfig.BODY_PARTS[partName]] = point; return true; } return false; } }