This commit is contained in:
terric 2023-11-27 14:46:43 +08:00
parent a2437a89c9
commit 1a0b118da1
8 changed files with 55 additions and 46 deletions

View File

@ -130145,7 +130145,7 @@ AnimationClip:
intParameter: 0
messageOptions: 0
- time: 41.133335
functionName: PlayCountDownSE
functionName: ActionBackStart
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0

View File

@ -183949,21 +183949,21 @@ AnimationClip:
intParameter: 1
messageOptions: 0
- time: 1.2333333
functionName: ActionHold
functionName: ActionRecheck
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 1
messageOptions: 0
- time: 2.9
functionName: StartSampling
- time: 2.9333334
functionName: PlayCountDownSE
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 3.1333334
functionName: PlayCountDownSE
functionName: StartSampling
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
@ -183990,13 +183990,6 @@ AnimationClip:
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 6.5666666
functionName: ActionHold
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 12
messageOptions: 0
- time: 6.8
functionName: ActionBackStart
data:
@ -184004,13 +183997,6 @@ AnimationClip:
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 9.766666
functionName: ActionHold
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 10.3
functionName: Evaluate
data:
@ -184025,8 +184011,22 @@ AnimationClip:
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 16.466667
functionName: StartSampling
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 17.733334
functionName: EndSampling
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 18.1
functionName: ActionHold
functionName: ActionRecheck
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
@ -184103,7 +184103,7 @@ AnimationClip:
intParameter: 1
messageOptions: 0
- time: 34.433334
functionName: ActionHold
functionName: ActionRecheck
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
@ -184180,7 +184180,7 @@ AnimationClip:
intParameter: 0
messageOptions: 0
- time: 51.166668
functionName: ActionHold
functionName: ActionRecheck
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0

View File

@ -15,15 +15,15 @@ public class LeftLateralHead : PoseBase
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);
//"REye", "LEye"
var startDir = "REye".vector(startP) - "LEye".vector(startP);
var endDir = "REye".vector(endP) - "LEye".vector(endP);
var angle = Vector2.SignedAngle(startDir, endDir);
LogPrint.Log($"angle: {angle}", PrintLevel.Normal);
LogPrint.Warning($"angle: {angle}", PrintLevel.Normal);
if (MathF.Abs(angle) > 10)
if (angle > 10)
{
return true;
}

View File

@ -106,15 +106,17 @@ public abstract class PoseBase
var vector = GetBasicVectorDirection(p1, p2);
distance += vector;
if (vector.magnitude > 0.1f) //如果矢量长度大于0.1f,说明有运动
{
TimeSpan timeSpan = points[i + 1].Item1 - points[i].Item1;
//if (vector.magnitude > 0.1f) //如果矢量长度大于0.1f,说明有运动
//{
// TimeSpan timeSpan = points[i + 1].Item1 - points[i].Item1;
if (totalTimeSpan == TimeSpan.MinValue)
totalTimeSpan = timeSpan;
else
totalTimeSpan += timeSpan;
}
// if (totalTimeSpan == TimeSpan.MinValue)
// totalTimeSpan = timeSpan;
// else
// totalTimeSpan += timeSpan;
//}
TimeSpan timeSpan = points[i + 1].Item1 - points[i].Item1;
totalTimeSpan = timeSpan;
}
LogPrint.Log($"distance: {distance}, totalTimeSpan: {totalTimeSpan}", PrintLevel.Normal);

View File

@ -15,15 +15,15 @@ public class RightLateralHead : PoseBase
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);
//"REye", "LEye"
var startDir = "REye".vector(startP) - "LEye".vector(startP);
var endDir = "REye".vector(endP) - "LEye".vector(endP);
var angle = Vector2.SignedAngle(startDir, endDir);
LogPrint.Log($"angle: {angle}", PrintLevel.Normal);
LogPrint.Warning($"angle: {angle}", PrintLevel.Normal);
if (MathF.Abs(angle) > 10)
if (angle < -10)
{
return true;
}

View File

@ -104,6 +104,9 @@ public class YogaManager : MonoSingleton<YogaManager>
_actions[AvatarAction.HeadTurnDown] = new HeadTurnDown();
_actions[AvatarAction.HandsUp] = new HandsUp();
_actions[AvatarAction.HandsDown] = new HandsHold();
_actions[AvatarAction.LeftLateralHead] = new LeftLateralHead();
_actions[AvatarAction.RightLateralHead] = new RightLateralHead();
_actions[AvatarAction.Hold] = new HoldPosition();
_currentCheckPointCount = 0;
_currentCheckPointSuccessCount = 0;
@ -119,6 +122,8 @@ public class YogaManager : MonoSingleton<YogaManager>
EventManager.Instance.AddEventListener(YogaEventType.Action_Success, OnActionSuccess);
EventManager.Instance.AddEventListener(YogaEventType.Action_Fail, OnActionFailed);
EventManager.Instance.AddEventListener(YogaEventType.Action_StartSampling, OnSamplingStart);
EventManager.Instance.AddEventListener(YogaEventType.Action_EndSampling, OnSamplingEnd);
EventManager.Instance.AddEventListener(YogaEventType.Action_Evaluate, OnEvaluation);
//extra event
EventManager.Instance.AddEventListener(YogaEventType.Action_MoveDistanceExactly, ExtraMoveDistanceExactly);

View File

@ -43,7 +43,7 @@ namespace Yoga
}
private void GCCollection()
{
if (_isOnCamCapture && enabled == true)
if (_isOnCamCapture && enabled == true && gameObject.activeInHierarchy == true)
StartCoroutine(CleanUp());
}
private IEnumerator CleanUp()

View File

@ -14,20 +14,20 @@ public class YogaDataLoader
data[-1] = new YogaData()
{
VideoPath = "Video/Action3",
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.SitUpright, AvatarAction.Nod },
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.HeadShake },
Action = AvatarAction.Nod,
ModelType = ModelType.OpenPose,
MaxCheckPointCount = 1000,
TotalSeconds = 20.0f,
RectCutRate = 0.2f,
MustPoints = new List<string>() { "Nose", /*"REye", "LEye", */"Neck" },
MustPoints = new List<string>() { "Nose", "Neck" },//{"REye", "LEye"}
//AnyPoints = new List<string>() { "RWrist", "LWrist" }
};
#endif
data[1] = new YogaData()
{
VideoPath = "Video/Action1",
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.SitUpright, AvatarAction.SitUpright, AvatarAction.HeadShake },
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.HeadShake },
Action = AvatarAction.HeadShake,
ModelType = ModelType.OpenPose,
MaxCheckPointCount = 4,
@ -38,6 +38,7 @@ public class YogaDataLoader
data[2] = new YogaData()
{
VideoPath = "Video/Action2",
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.Nod },
Action = AvatarAction.Nod,
ModelType = ModelType.OpenPose,
MaxCheckPointCount = 4,
@ -48,11 +49,12 @@ public class YogaDataLoader
data[3] = new YogaData()
{
VideoPath = "Video/Action3",
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.LateralHead },
Action = AvatarAction.LateralHead,
ModelType = ModelType.MediapipePose,
ModelType = ModelType.OpenPose,
MaxCheckPointCount = 4,
TotalSeconds = 12.66f,
MustPoints = new List<string>() { "Nose", "RShoulder", "LShoulder", "RElbow", "LElbow" }
MustPoints = new List<string>() { "REye", "LEye" }
};
if (data.ContainsKey(index))