2023-11-12 15:09:33 +00:00
|
|
|
|
using OpenCVForUnity.CoreModule;
|
2023-11-07 13:55:35 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2023-11-12 15:09:33 +00:00
|
|
|
|
public static class YogaConfig
|
2023-11-07 13:55:35 +00:00
|
|
|
|
{
|
|
|
|
|
public static readonly Dictionary<string, int> BODY_PARTS = new Dictionary<string, int>()
|
|
|
|
|
{
|
|
|
|
|
{ "Nose", 0 }, //{ "Nose", 0 },
|
|
|
|
|
{ "Neck", 1 }, //{ "Neck", 1 },
|
|
|
|
|
{ "LShoulder", 2 }, //{ "RShoulder", 2 },
|
|
|
|
|
{ "LElbow", 3 }, //{ "RElbow", 3 },
|
|
|
|
|
{ "LWrist", 4 }, //{ "RWrist", 4 },
|
|
|
|
|
{ "RShoulder",5 }, //{ "LShoulder",5 },
|
|
|
|
|
{ "RElbow", 6 }, //{ "LElbow", 6 },
|
|
|
|
|
{ "RWrist", 7 }, //{ "LWrist", 7 },
|
|
|
|
|
{ "LHip", 8 }, //{ "RHip", 8 },
|
|
|
|
|
{ "LKnee", 9 }, //{ "RKnee", 9 },
|
|
|
|
|
{ "LAnkle", 10 }, //{ "RAnkle", 10 },
|
|
|
|
|
{ "RHip", 11 }, //{ "LHip", 11 },
|
|
|
|
|
{ "RKnee", 12 }, //{ "LKnee", 12 },
|
|
|
|
|
{ "RAnkle", 13 }, //{ "LAnkle", 13 },
|
|
|
|
|
{ "LEye", 14 }, //{ "REye", 14 },
|
|
|
|
|
{ "REye", 15 }, //{ "LEye", 15 },
|
|
|
|
|
{ "LEar", 16 }, //{ "REar", 16 },
|
|
|
|
|
{ "REar", 17 }, //{ "LEar", 17 },
|
|
|
|
|
{ "Background", 18 } //{ "Background", 18 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static readonly string[,] POSE_PAIRS = new string[,]
|
|
|
|
|
{
|
|
|
|
|
{ "Neck", "RShoulder" },
|
|
|
|
|
{ "Neck", "LShoulder" },
|
|
|
|
|
{ "RShoulder", "RElbow" },
|
|
|
|
|
{ "RElbow", "RWrist" },
|
|
|
|
|
{ "LShoulder", "LElbow" },
|
|
|
|
|
{ "LElbow", "LWrist" },
|
|
|
|
|
{ "Neck", "RHip" },
|
|
|
|
|
{ "RHip", "RKnee" },
|
|
|
|
|
{ "RKnee", "RAnkle" },
|
|
|
|
|
{ "Neck", "LHip" },
|
|
|
|
|
{ "LHip", "LKnee" },
|
|
|
|
|
{ "LKnee", "LAnkle" },
|
|
|
|
|
{ "Neck", "Nose" },
|
|
|
|
|
{ "Nose", "REye" },
|
|
|
|
|
{ "REye", "REar" },
|
|
|
|
|
{ "Nose", "LEye" },
|
|
|
|
|
{ "LEye", "LEar" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public const float InWidth = 256;
|
|
|
|
|
public const float InHeight = 256;
|
|
|
|
|
public const float InScale = 1.0f / 255;
|
|
|
|
|
|
|
|
|
|
public static readonly Dictionary<ModelType, string> MODEL_PATHS = new Dictionary<ModelType, string>()
|
|
|
|
|
{
|
|
|
|
|
{ModelType.OpenPose,"OpenCVForUnity/dnn/lightweight_pose_estimation_201912.onnx" },
|
|
|
|
|
//{"","" },
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-12 15:09:33 +00:00
|
|
|
|
public static int index(this string tagName)
|
|
|
|
|
{
|
|
|
|
|
if (!BODY_PARTS.ContainsKey(tagName))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("TagName is not exist");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return BODY_PARTS[tagName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Point p(this List<Point> points, string tagName)
|
|
|
|
|
{
|
|
|
|
|
if (!BODY_PARTS.ContainsKey(tagName))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("TagName is not exist");
|
|
|
|
|
return new Point(-1, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return points[BODY_PARTS[tagName]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Point p(this string tagName, List<Point> points)
|
|
|
|
|
{
|
|
|
|
|
if (!BODY_PARTS.ContainsKey(tagName))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("TagName is not exist");
|
|
|
|
|
return new Point(-1, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (points == null)
|
|
|
|
|
return new Point(-1, -1);
|
|
|
|
|
|
|
|
|
|
return points[BODY_PARTS[tagName]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsValid(this string partName, List<Point> points)
|
|
|
|
|
{
|
|
|
|
|
if (points == null || points.Count < BODY_PARTS.Count)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
var point = points[BODY_PARTS[partName]];
|
|
|
|
|
if (point == new Point(-1, -1))
|
|
|
|
|
{
|
|
|
|
|
Debug.Log($"{partName}<7D><><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 13:55:35 +00:00
|
|
|
|
public static readonly double[] InMean = new double[] { 128.0, 128.0, 128.0 };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum ModelType
|
|
|
|
|
{
|
|
|
|
|
OpenPose,
|
|
|
|
|
YoloV7,
|
|
|
|
|
//,
|
|
|
|
|
}
|