Health/Assets/Scripts/YogaDataLoader.cs

89 lines
2.7 KiB
C#

using System.Collections.Generic;
using UnityEngine;
public class YogaDataLoader
{
public static YogaData LoadData(int index)
{
//Resources.Load<TextAsset>("YogaActions/YogaAction" + ActionIndex);
Dictionary<int, YogaData> data = new Dictionary<int, YogaData>();
#if UNITY_EDITOR
data[-1] = new YogaData()
{
VideoPath = "Video/Action3",
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.SitUpright, AvatarAction.Nod },
Action = AvatarAction.Nod,
ModelType = ModelType.OpenPose,
MaxCheckPointCount = 1000,
TotalSeconds = 20.0f,
RectCutRate = 0.2f,
MustPoints = new List<string>() { "Nose", /*"REye", "LEye", */"Neck" },
//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 },
Action = AvatarAction.HeadShake,
ModelType = ModelType.OpenPose,
MaxCheckPointCount = 4,
TotalSeconds = 20.0f,
RectCutRate = 0.25f,
MustPoints = new List<string>() { "Nose", /*"REye", "LEye", */"Neck" }
};
data[2] = new YogaData()
{
VideoPath = "Video/Action2",
Action = AvatarAction.Nod,
ModelType = ModelType.OpenPose,
MaxCheckPointCount = 4,
TotalSeconds = 20.0f,
RectCutRate = 0.25f,
MustPoints = new List<string>() { "Nose",/* "REye", "LEye", */"Neck" }
};
data[3] = new YogaData()
{
VideoPath = "Video/Action3",
Action = AvatarAction.LateralHead,
ModelType = ModelType.MediapipePose,
MaxCheckPointCount = 4,
TotalSeconds = 12.66f,
MustPoints = new List<string>() { "Nose", "RShoulder", "LShoulder", "RElbow", "LElbow" }
};
if (data.ContainsKey(index))
return data[index];
else
{
LogPrint.Error("YogaDataLoader.LoadData: index out of range");
}
return null;
}
}
public class YogaData
{
public string VideoPath;
internal List<AvatarAction> Actions;
public AvatarAction Action;
public ModelType ModelType;
public int MaxCheckPointCount;
public float TotalSeconds;
public float RectCutRate;
public List<string> MustPoints = new List<string>();
public List<string> AnyPoints = new List<string>();
}
public enum ModelType
{
OpenPose,
YoloV7,
MediapipePose,
MediapipePersonDetect,
//,
}