Health/Assets/Scripts/PoseCheck/HandsUp.cs

46 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using OpenCVForUnity.CoreModule;
using System;
using System.Collections.Generic;
using UnityEngine;
public class HandsUp : PoseBase
{
public override Vector2 GetBasicVectorDirection(List<Point> startPoint, List<Point> endPoint)
{
//必要点位 "RShoulder", "LShoulder", "RElbow", "LElbow"
//计算肩膀到手肘矢量,右手
//Vector2 rightHandVector = GetAverageVector(startPoint, endPoint, "RElbow");
//Vector2 leftHandVector = GetAverageVector(startPoint, endPoint, "LElbow");
Vector2 rightHandVector = GetTwoPointAverageVector(startPoint, endPoint, "RElbow", "RShoulder");
Vector2 leftHandVector = GetTwoPointAverageVector(startPoint, endPoint, "LElbow", "LShoulder");
//平均矢量
Vector2 averageVector = (rightHandVector + leftHandVector) / 2;
//如果左右手肘矢量差小于两者平均值的0.3倍且左右手矢量夹角小于30度返回左右手矢量平均值
if ((rightHandVector - leftHandVector).magnitude < averageVector.magnitude * 0.3f
&& Vector2.Angle(rightHandVector, leftHandVector) < 30)
{
return averageVector;
}
return Vector2.zero;
}
protected override bool IsMovePoint(string tagName)
{
return "RWrist".Equals(tagName) ||
"LWrist".Equals(tagName);
}
public override bool? MovementValidation(Vector2 distance, TimeSpan totalTimeSpan, int level)
{
return BasicMovementValidation(distance, totalTimeSpan, Vector2.up, level);
}
public override void ExcellenceEstimate(List<(TimeSpan, Vector2)> frameData, Vector2 distance, TimeSpan totalTimeSpan)
{
throw new NotImplementedException();
}
}