Health/Assets/Scripts/YogaDataLoader.cs

86 lines
2.7 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",
2023-11-27 18:00:13 +00:00
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.Nod },
//Action = AvatarAction.Nod,
ModelType = ModelType.OpenPose,
2023-11-27 05:49:53 +00:00
MaxCheckPointCount = 1000,
2023-11-24 12:04:16 +00:00
RectCutRate = 0.2f,
2023-11-27 06:46:43 +00:00
MustPoints = new List<string>() { "Nose", "Neck" },//{"REye", "LEye"}
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",
2023-11-27 06:46:43 +00:00
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.HeadShake },
2023-11-27 18:00:13 +00:00
//Action = AvatarAction.HeadShake,
2023-11-15 08:10:56 +00:00
ModelType = ModelType.OpenPose,
2023-11-27 05:49:53 +00:00
MaxCheckPointCount = 4,
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",
2023-11-27 06:46:43 +00:00
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.Nod },
2023-11-27 18:00:13 +00:00
//Action = AvatarAction.Nod,
2023-11-15 08:10:56 +00:00
ModelType = ModelType.OpenPose,
2023-11-27 05:49:53 +00:00
MaxCheckPointCount = 4,
2023-11-24 12:04:16 +00:00
RectCutRate = 0.25f,
2023-11-27 05:49:53 +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",
2023-11-27 06:46:43 +00:00
Actions = new List<AvatarAction>() { AvatarAction.SitUpright, AvatarAction.LateralHead },
2023-11-27 18:00:13 +00:00
//Action = AvatarAction.LateralHead,
2023-11-27 06:46:43 +00:00
ModelType = ModelType.OpenPose,
2023-11-27 05:49:53 +00:00
MaxCheckPointCount = 4,
2023-11-27 06:46:43 +00:00
MustPoints = new List<string>() { "REye", "LEye" }
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;
2023-11-27 05:49:53 +00:00
internal List<AvatarAction> Actions;
2023-11-27 18:00:13 +00:00
//public AvatarAction Action;
2023-11-15 08:10:56 +00:00
public ModelType ModelType;
2023-11-27 05:49:53 +00:00
public int MaxCheckPointCount;
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
}