Health/Assets/Scripts/YogaDataLoader.cs

86 lines
2.4 KiB
C#
Raw Normal View History

2023-11-10 07:17:23 +00:00
using System.Collections.Generic;
using UnityEngine;
public class YogaDataLoader
{
2023-11-14 10:52:43 +00:00
public static YogaData LoadData(int index)
2023-11-10 07:17:23 +00:00
{
//Resources.Load<TextAsset>("YogaActions/YogaAction" + ActionIndex);
2023-11-14 10:52:43 +00:00
Dictionary<int, YogaData> data = new Dictionary<int, YogaData>();
2023-11-12 15:09:33 +00:00
#if UNITY_EDITOR
2023-11-14 10:52:43 +00:00
data[-1] = new YogaData()
2023-11-12 15:09:33 +00:00
{
2023-11-15 17:23:16 +00:00
VideoPath = "Video/Action3",
Action = AvatarAction.HeadShake,
ModelType = ModelType.OpenPose,
2023-11-12 15:09:33 +00:00
MaxActionCount = 1000,
2023-11-14 10:52:43 +00:00
TotalSeconds = 20.0f,
2023-11-24 12:04:16 +00:00
RectCutRate = 0.2f,
MustPoints = new List<string>() { "Nose", "REye", "LEye", "Neck" },
2023-11-13 06:43:34 +00:00
//AnyPoints = new List<string>() { "RWrist", "LWrist" }
2023-11-12 15:09:33 +00:00
};
#endif
2023-11-14 10:52:43 +00:00
data[1] = new YogaData()
2023-11-12 15:09:33 +00:00
{
VideoPath = "Video/Action1",
Action = AvatarAction.HeadShake,
2023-11-15 08:10:56 +00:00
ModelType = ModelType.OpenPose,
2023-11-12 15:09:33 +00:00
MaxActionCount = 4,
2023-11-14 10:52:43 +00:00
TotalSeconds = 20.0f,
2023-11-24 12:04:16 +00:00
RectCutRate = 0.25f,
MustPoints = new List<string>() { "Nose", /*"REye", "LEye", */"Neck" }
2023-11-12 15:09:33 +00:00
};
2023-11-14 10:52:43 +00:00
data[2] = new YogaData()
2023-11-12 15:09:33 +00:00
{
VideoPath = "Video/Action2",
Action = AvatarAction.Nod,
2023-11-15 08:10:56 +00:00
ModelType = ModelType.OpenPose,
2023-11-12 15:09:33 +00:00
MaxActionCount = 4,
2023-11-14 10:52:43 +00:00
TotalSeconds = 20.0f,
2023-11-24 12:04:16 +00:00
RectCutRate = 0.25f,
2023-11-13 02:53:34 +00:00
MustPoints = new List<string>() { "Nose", "REye", "LEye", "Neck" }
2023-11-12 15:09:33 +00:00
};
2023-11-14 10:52:43 +00:00
data[3] = new YogaData()
2023-11-12 15:09:33 +00:00
{
VideoPath = "Video/Action3",
Action = AvatarAction.HandsUp,
2023-11-15 17:23:16 +00:00
ModelType = ModelType.MediapipePose,
2023-11-12 15:09:33 +00:00
MaxActionCount = 4,
2023-11-14 10:52:43 +00:00
TotalSeconds = 12.66f,
2023-11-15 17:23:16 +00:00
MustPoints = new List<string>() { "Nose", "RShoulder", "LShoulder", "RElbow", "LElbow" }
2023-11-12 15:09:33 +00:00
};
2023-11-10 07:17:23 +00:00
if (data.ContainsKey(index))
return data[index];
else
{
2023-11-24 05:13:10 +00:00
LogPrint.Error("YogaDataLoader.LoadData: index out of range");
2023-11-10 07:17:23 +00:00
}
2023-11-12 15:09:33 +00:00
2023-11-10 07:17:23 +00:00
return null;
}
}
2023-11-14 10:52:43 +00:00
public class YogaData
2023-11-10 07:17:23 +00:00
{
public string VideoPath;
public AvatarAction Action;
2023-11-15 08:10:56 +00:00
public ModelType ModelType;
2023-11-10 07:17:23 +00:00
public int MaxActionCount;
2023-11-14 10:52:43 +00:00
public float TotalSeconds;
2023-11-24 12:04:16 +00:00
public float RectCutRate;
2023-11-12 15:09:33 +00:00
public List<string> MustPoints = new List<string>();
2023-11-13 06:43:34 +00:00
public List<string> AnyPoints = new List<string>();
2023-11-15 08:10:56 +00:00
}
public enum ModelType
{
OpenPose,
YoloV7,
2023-11-15 17:23:16 +00:00
MediapipePose,
MediapipePersonDetect,
2023-11-15 08:10:56 +00:00
//,
2023-11-10 07:17:23 +00:00
}