59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using OpenCVForUnity.CoreModule;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class RightLateralHead : PoseBase
|
|
{
|
|
public override bool? AnalyzingAction(List<(DateTime, List<Point>)> points, bool isDataReGather = false)
|
|
{
|
|
if (points.Count < 2) // 0级实现逻辑 不做操作
|
|
return null;
|
|
|
|
var pointList = points.OrderBy(p => p.Item1);
|
|
var startP = points.First().Item2;
|
|
var endP = points.Last().Item2;
|
|
|
|
var startDir = "Nose".vector(startP) - "Neck".vector(startP);
|
|
var endDir = "Nose".vector(endP) - "Neck".vector(endP);
|
|
|
|
var angle = Vector2.SignedAngle(startDir, endDir);
|
|
|
|
LogPrint.Log($"angle: {angle}", PrintLevel.Normal);
|
|
|
|
if (MathF.Abs(angle) > 10)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
//public override Vector2 GetBasicVectorDirection(List<Point> startPoint, List<Point> endPoint)
|
|
//{
|
|
// List<Vector2> vectors = new List<Vector2>();
|
|
// //必要点位 Nose Neck
|
|
// //计算鼻子到头颈矢量
|
|
// //return GetAverageVector(startPoint, endPoint, "Nose");
|
|
// return GetTwoPointAverageVector(startPoint, endPoint, "Nose", "Neck");
|
|
//}
|
|
|
|
protected override bool IsMovePoint(string tagName)
|
|
{
|
|
return "Nose" == tagName || "REye" == tagName || "LEye" == tagName || "REar" == tagName || "LEar" == tagName;
|
|
}
|
|
|
|
public override bool? MovementValidation(Vector2 distance, TimeSpan totalTimeSpan, int level)
|
|
{
|
|
return BasicMovementValidation(distance, totalTimeSpan, Vector2.right, level);
|
|
}
|
|
|
|
public override void ExcellenceEstimate(List<(TimeSpan, Vector2)> frameData, Vector2 distance, TimeSpan totalTimeSpan)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|