update the generate bones function, to account for different number of bones in each model:
public enum MPIIJoint : byte
{
RightAnkle = 0, // 0
RightKnee = 1, // 1
RightHip = 2, // 2
LeftHip = 3, // 3
LeftKnee = 4, // 4
LeftAnkle = 5, // 5
Pelvis = 6, // 6
Thorax = 7, // 7
Neck = 8, // 8
HeadTop = 9, // 9
RightWrist = 10, // 10
RightElbow = 11, // 11
RightShoulder = 12, // 12
LeftShoulder = 13, // 13
LeftElbow = 14, // 14
LeftWrist = 15 // 15
}
public enum COCOKeypoint : byte
{
Nose = 0, // 0
LeftEye = 1, // 1
RightEye = 2, // 2
LeftEar = 3, // 3
RightEar = 4, // 4
LeftShoulder = 5, // 5
RightShoulder = 6, // 6
LeftElbow = 7, // 7
RightElbow = 8, // 8
LeftWrist = 9, // 9
RightWrist = 10, // 10
LeftHip = 11, // 11
RightHip = 12, // 12
LeftKnee = 13, // 13
RightKnee = 14, // 14
LeftAnkle = 15, // 15
RightAnkle = 16 // 16
}
public enum PoseTrackKeypoint : byte
{
Nose = 0, // 0
HeadBottom = 1, // 1
Neck = 2, // 2
RightShoulder = 3, // 3
RightElbow = 4, // 4
RightWrist = 5, // 5
LeftShoulder = 6, // 6
LeftElbow = 7, // 7
LeftWrist = 8, // 8
RightHip = 9, // 9
RightKnee = 10, // 10
RightAnkle = 11, // 11
LeftHip = 12, // 12
LeftKnee = 13, // 13
LeftAnkle = 14, // 14
RightEye = 15, // 15
LeftEye = 16, // 16
RightEar = 17, // 17
LeftEar = 18 // 18
}
public enum H36MJoint : byte
{
Hip = 0, // 0 (Root joint)
RightHip = 1, // 1
RightKnee = 2, // 2
RightAnkle = 3, // 3
LeftHip = 4, // 4
LeftKnee = 5, // 5
LeftAnkle = 6, // 6
Spine = 7, // 7
Thorax = 8, // 8
Neck = 9, // 9
Head = 10, // 10
LeftShoulder = 11, // 11
LeftElbow = 12, // 12
LeftWrist = 13, // 13
RightShoulder = 14, // 14
RightElbow = 15, // 15
RightWrist = 16 // 16
}
public enum MediaPipeKeypoint : byte
{
Nose = 0, // 0
LeftEyeInner = 1, // 1
LeftEye = 2, // 2
LeftEyeOuter = 3, // 3
RightEyeInner = 4, // 4
RightEye = 5, // 5
RightEyeOuter = 6, // 6
LeftEar = 7, // 7
RightEar = 8, // 8
MouthLeft = 9, // 9
MouthRight = 10, // 10
LeftShoulder = 11, // 11
RightShoulder = 12, // 12
LeftElbow = 13, // 13
RightElbow = 14, // 14
LeftWrist = 15, // 15
RightWrist = 16, // 16
LeftPinky = 17, // 17
RightPinky = 18, // 18
LeftIndex = 19, // 19
RightIndex = 20, // 20
LeftThumb = 21, // 21
RightThumb = 22, // 22
LeftHip = 23, // 23
RightHip = 24, // 24
LeftKnee = 25, // 25
RightKnee = 26, // 26
LeftAnkle = 27, // 27
RightAnkle = 28, // 28
LeftHeel = 29, // 29
RightHeel = 30, // 30
LeftFootIndex = 31, // 31
RightFootIndex = 32 // 32
}
using System.Collections.Generic;
using UnchartedLimbo.Core.Utilities.DataStructures;
using UnityEngine;
[CreateAssetMenu(menuName = “Uncharted Limbo/Monolith/Pose Models/MPII”)]
public class MPIIModel : SkeletonModelBase
{
protected override Dictionary<byte, HumanBodyBones> BuildJointDictionary() =>
new ()
{
{ (byte) MPIIJoint.Pelvis, HumanBodyBones.Hips },
{ (byte) MPIIJoint.Thorax, HumanBodyBones.UpperChest },
{ (byte) MPIIJoint.Neck, HumanBodyBones.Neck },
{ (byte) MPIIJoint.HeadTop, HumanBodyBones.Head },
{ (byte) MPIIJoint.RightShoulder, HumanBodyBones.RightUpperArm },
{ (byte) MPIIJoint.RightElbow, HumanBodyBones.RightLowerArm },
{ (byte) MPIIJoint.RightWrist, HumanBodyBones.RightHand },
{ (byte) MPIIJoint.LeftShoulder, HumanBodyBones.LeftUpperArm },
{ (byte) MPIIJoint.LeftElbow, HumanBodyBones.LeftLowerArm },
{ (byte) MPIIJoint.LeftWrist, HumanBodyBones.LeftHand },
{ (byte) MPIIJoint.RightHip, HumanBodyBones.RightUpperLeg },
{ (byte) MPIIJoint.RightKnee, HumanBodyBones.RightLowerLeg },
{ (byte) MPIIJoint.RightAnkle, HumanBodyBones.RightFoot },
{ (byte) MPIIJoint.LeftHip, HumanBodyBones.LeftUpperLeg },
{ (byte) MPIIJoint.LeftKnee, HumanBodyBones.LeftLowerLeg },
{ (byte) MPIIJoint.LeftAnkle, HumanBodyBones.LeftFoot }
public override bool IsRightSideJoint(byte joint) =>
joint is
(byte)MPIIJoint.RightShoulder or
(byte)MPIIJoint.RightElbow or
(byte)MPIIJoint.RightWrist or
(byte)MPIIJoint.RightHip or
(byte)MPIIJoint.RightKnee or
(byte)MPIIJoint.RightAnkle;
public override bool IsLeftSideJoint(byte joint)
=> joint is
(byte)MPIIJoint.LeftShoulder or
(byte)MPIIJoint.LeftElbow or
(byte)MPIIJoint.LeftWrist or
(byte)MPIIJoint.LeftHip or
(byte)MPIIJoint.LeftKnee or
(byte)MPIIJoint.LeftAnkle;
public Dictionary<string, (byte, byte)> GenerateBonesArray() =>
new ()
{
{ “RightUpperLeg”, ((byte)MPIIJoint.RightHip, (byte)MPIIJoint.RightKnee) },
{ “RightLowerLeg”, ((byte)MPIIJoint.RightKnee, (byte)MPIIJoint.RightAnkle) },
{ “LeftUpperLeg”, ((byte)MPIIJoint.LeftHip, (byte)MPIIJoint.LeftKnee) },
{ “LeftLowerLeg”, ((byte)MPIIJoint.LeftKnee, (byte)MPIIJoint.LeftAnkle) },
{ “Spine”, ((byte)MPIIJoint.Pelvis, (byte)MPIIJoint.Thorax) },
{ “Neck”, ((byte)MPIIJoint.Thorax, (byte)MPIIJoint.Neck) },
{ “Head”, ((byte)MPIIJoint.Neck, (byte)MPIIJoint.HeadTop) },
{ “RightUpperArm”, ((byte)MPIIJoint.RightShoulder, (byte)MPIIJoint.RightElbow) },
{ “RightLowerArm”, ((byte)MPIIJoint.RightElbow, (byte)MPIIJoint.RightWrist) },
{ “LeftUpperArm”, ((byte)MPIIJoint.LeftShoulder, (byte)MPIIJoint.LeftElbow) },
{ “LeftLowerArm”, ((byte)MPIIJoint.LeftElbow, (byte)MPIIJoint.LeftWrist) }
};
}
[CreateAssetMenu(menuName = “Uncharted Limbo/Monolith/Pose Models/COCO”)]
public class COCOModel : SkeletonModelBase
{
protected override Dictionary<byte, HumanBodyBones> BuildJointDictionary() =>
new ()
{
{ (byte) COCOKeypoint.LeftShoulder, HumanBodyBones.LeftUpperArm },
{ (byte) COCOKeypoint.RightShoulder, HumanBodyBones.RightUpperArm },
{ (byte) COCOKeypoint.LeftElbow, HumanBodyBones.LeftLowerArm },
{ (byte) COCOKeypoint.RightElbow, HumanBodyBones.RightLowerArm },
{ (byte) COCOKeypoint.LeftWrist, HumanBodyBones.LeftHand },
{ (byte) COCOKeypoint.RightWrist, HumanBodyBones.RightHand },
{ (byte) COCOKeypoint.LeftHip, HumanBodyBones.LeftUpperLeg },
{ (byte) COCOKeypoint.RightHip, HumanBodyBones.RightUpperLeg },
{ (byte) COCOKeypoint.LeftKnee, HumanBodyBones.LeftLowerLeg },
{ (byte) COCOKeypoint.RightKnee, HumanBodyBones.RightLowerLeg },
{ (byte) COCOKeypoint.LeftAnkle, HumanBodyBones.LeftFoot },
{ (byte) COCOKeypoint.RightAnkle, HumanBodyBones.RightFoot }
};
public override bool IsRightSideJoint(byte joint) =>
joint is
(byte)COCOKeypoint.RightShoulder or
(byte)COCOKeypoint.RightElbow or
(byte)COCOKeypoint.RightWrist or
(byte)COCOKeypoint.RightHip or
(byte)COCOKeypoint.RightKnee or
(byte)COCOKeypoint.RightAnkle;
public override bool IsLeftSideJoint(byte joint)
=> joint is
(byte)COCOKeypoint.LeftShoulder or
(byte)COCOKeypoint.LeftElbow or
(byte)COCOKeypoint.LeftWrist or
(byte)COCOKeypoint.LeftHip or
(byte)COCOKeypoint.LeftKnee or
(byte)COCOKeypoint.LeftAnkle;
public Dictionary<string, (byte, byte)> GenerateBonesArray() =>
new ()
{
{ “RightUpperLeg”, ((byte)COCOKeypoint.RightHip, (byte)COCOKeypoint.RightKnee) },
{ “RightLowerLeg”, ((byte)COCOKeypoint.RightKnee, (byte)COCOKeypoint.RightAnkle) },
{ “LeftUpperLeg”, ((byte)COCOKeypoint.LeftHip, (byte)COCOKeypoint.LeftKnee) },
{ “LeftLowerLeg”, ((byte)COCOKeypoint.LeftKnee, (byte)COCOKeypoint.LeftAnkle) },
{ “RightUpperArm”, ((byte)COCOKeypoint.RightShoulder, (byte)COCOKeypoint.RightElbow) },
{ “RightLowerArm”, ((byte)COCOKeypoint.RightElbow, (byte)COCOKeypoint.RightWrist) },
{ “LeftUpperArm”, ((byte)COCOKeypoint.LeftShoulder, (byte)COCOKeypoint.LeftElbow) },
{ “LeftLowerArm”, ((byte)COCOKeypoint.LeftElbow, (byte)COCOKeypoint.LeftWrist) }
};
}
[CreateAssetMenu(menuName = “Uncharted Limbo/Monolith/Pose Models/PoseTrack”)]
public class PoseTrackModel : SkeletonModelBase
{
protected override Dictionary<byte, HumanBodyBones> BuildJointDictionary() =>
new ()
{
{ (byte) PoseTrackKeypoint.Neck, HumanBodyBones.Neck },
{ (byte) PoseTrackKeypoint.LeftShoulder, HumanBodyBones.LeftUpperArm },
{ (byte) PoseTrackKeypoint.RightShoulder, HumanBodyBones.RightUpperArm },
{ (byte) PoseTrackKeypoint.LeftElbow, HumanBodyBones.LeftLowerArm },
{ (byte) PoseTrackKeypoint.RightElbow, HumanBodyBones.RightLowerArm },
{ (byte) PoseTrackKeypoint.LeftWrist, HumanBodyBones.LeftHand },
{ (byte) PoseTrackKeypoint.RightWrist, HumanBodyBones.RightHand },
{ (byte) PoseTrackKeypoint.LeftHip, HumanBodyBones.LeftUpperLeg },
{ (byte) PoseTrackKeypoint.RightHip, HumanBodyBones.RightUpperLeg },
{ (byte) PoseTrackKeypoint.LeftKnee, HumanBodyBones.LeftLowerLeg },
{ (byte) PoseTrackKeypoint.RightKnee, HumanBodyBones.RightLowerLeg },
{ (byte) PoseTrackKeypoint.LeftAnkle, HumanBodyBones.LeftFoot },
{ (byte) PoseTrackKeypoint.RightAnkle, HumanBodyBones.RightFoot }
};
public override bool IsRightSideJoint(byte joint) =>
joint is
(byte)PoseTrackKeypoint.RightShoulder or
(byte)PoseTrackKeypoint.RightElbow or
(byte)PoseTrackKeypoint.RightWrist or
(byte)PoseTrackKeypoint.RightHip or
(byte)PoseTrackKeypoint.RightKnee or
(byte)PoseTrackKeypoint.RightAnkle;
public override bool IsLeftSideJoint(byte joint)
=> joint is
(byte)PoseTrackKeypoint.LeftShoulder or
(byte)PoseTrackKeypoint.LeftElbow or
(byte)PoseTrackKeypoint.LeftWrist or
(byte)PoseTrackKeypoint.LeftHip or
(byte)PoseTrackKeypoint.LeftKnee or
(byte)PoseTrackKeypoint.LeftAnkle;
public Dictionary<string, (byte, byte)> GenerateBonesArray() =>
new ()
{
{ “RightUpperLeg”, ((byte)PoseTrackKeypoint.RightHip, (byte)PoseTrackKeypoint.RightKnee) },
{ “RightLowerLeg”, ((byte)PoseTrackKeypoint.RightKnee, (byte)PoseTrackKeypoint.RightAnkle) },
{ “LeftUpperLeg”, ((byte)PoseTrackKeypoint.LeftHip, (byte)PoseTrackKeypoint.LeftKnee) },
{ “LeftLowerLeg”, ((byte)PoseTrackKeypoint.LeftKnee, (byte)PoseTrackKeypoint.LeftAnkle) },
{ “RightUpperArm”, ((byte)PoseTrackKeypoint.RightShoulder, (byte)PoseTrackKeypoint.RightElbow) },
{ “RightLowerArm”, ((byte)PoseTrackKeypoint.RightElbow, (byte)PoseTrackKeypoint.RightWrist) },
{ “LeftUpperArm”, ((byte)PoseTrackKeypoint.LeftShoulder, (byte)PoseTrackKeypoint.LeftElbow) },
{ “LeftLowerArm”, ((byte)PoseTrackKeypoint.LeftElbow, (byte)PoseTrackKeypoint.LeftWrist) }
};
}
[CreateAssetMenu(menuName = “Uncharted Limbo/Monolith/Pose Models/H36M”)]
public class H36MModel : SkeletonModelBase
{
protected override Dictionary<byte, HumanBodyBones> BuildJointDictionary() =>
new ()
{
{ (byte) H36MJoint.Hip, HumanBodyBones.Hips },
{ (byte) H36MJoint.Spine, HumanBodyBones.Spine },
{ (byte) H36MJoint.Thorax, HumanBodyBones.UpperChest },
{ (byte) H36MJoint.Neck, HumanBodyBones.Neck },
{ (byte) H36MJoint.Head, HumanBodyBones.Head },
{ (byte) H36MJoint.LeftShoulder, HumanBodyBones.LeftUpperArm },
{ (byte) H36MJoint.RightShoulder, HumanBodyBones.RightUpperArm },
{ (byte) H36MJoint.LeftElbow, HumanBodyBones.LeftLowerArm },
{ (byte) H36MJoint.RightElbow, HumanBodyBones.RightLowerArm },
{ (byte) H36MJoint.LeftWrist, HumanBodyBones.LeftHand },
{ (byte) H36MJoint.RightWrist, HumanBodyBones.RightHand },
{ (byte) H36MJoint.LeftHip, HumanBodyBones.LeftUpperLeg },
{ (byte) H36MJoint.RightHip, HumanBodyBones.RightUpperLeg },
{ (byte) H36MJoint.LeftKnee, HumanBodyBones.LeftLowerLeg },
{ (byte) H36MJoint.RightKnee, HumanBodyBones.RightLowerLeg },
{ (byte) H36MJoint.LeftAnkle, HumanBodyBones.LeftFoot },
{ (byte) H36MJoint.RightAnkle, HumanBodyBones.RightFoot }
};
public override bool IsRightSideJoint(byte joint) =>
joint is
(byte)H36MJoint.RightShoulder or
(byte)H36MJoint.RightElbow or
(byte)H36MJoint.RightWrist or
(byte)H36MJoint.RightHip or
(byte)H36MJoint.RightKnee or
(byte)H36MJoint.RightAnkle;
public override bool IsLeftSideJoint(byte joint)
=> joint is
(byte)H36MJoint.LeftShoulder or
(byte)H36MJoint.LeftElbow or
(byte)H36MJoint.LeftWrist or
(byte)H36MJoint.LeftHip or
(byte)H36MJoint.LeftKnee or
(byte)H36MJoint.LeftAnkle;
public Dictionary<string, (byte, byte)> GenerateBonesArray() =>
new ()
{
{ “RightUpperLeg”, ((byte)H36MJoint.RightHip, (byte)H36MJoint.RightKnee) },
{ “RightLowerLeg”, ((byte)H36MJoint.RightKnee, (byte)H36MJoint.RightAnkle) },
{ “LeftUpperLeg”, ((byte)H36MJoint.LeftHip, (byte)H36MJoint.LeftKnee) },
{ “LeftLowerLeg”, ((byte)H36MJoint.LeftKnee, (byte)H36MJoint.LeftAnkle) },
{ “Spine”, ((byte)H36MJoint.Hip, (byte)H36MJoint.Spine) },
{ “Thorax”, ((byte)H36MJoint.Spine, (byte)H36MJoint.Thorax) },
{ “Neck”, ((byte)H36MJoint.Thorax, (byte)H36MJoint.Neck) },
{ “Head”, ((byte)H36MJoint.Neck, (byte)H36MJoint.Head) },
{ “RightUpperArm”, ((byte)H36MJoint.RightShoulder, (byte)H36MJoint.RightElbow) },
{ “RightLowerArm”, ((byte)H36MJoint.RightElbow, (byte)H36MJoint.RightWrist) },
{ “LeftUpperArm”, ((byte)H36MJoint.LeftShoulder, (byte)H36MJoint.LeftElbow) },
{ “LeftLowerArm”, ((byte)H36MJoint.LeftElbow, (byte)H36MJoint.LeftWrist) }
};
}
[CreateAssetMenu(menuName = “Uncharted Limbo/Monolith/Pose Models/MediaPipe”)]
public class MediaPipeModel : SkeletonModelBase
{
protected override Dictionary<byte, HumanBodyBones> BuildJointDictionary() =>
new ()
{
{ (byte) MediaPipeKeypoint.Nose, HumanBodyBones.Head },
{ (byte) MediaPipeKeypoint.LeftShoulder, HumanBodyBones.LeftUpperArm },
{ (byte) MediaPipeKeypoint.RightShoulder, HumanBodyBones.RightUpperArm },
{ (byte) MediaPipeKeypoint.LeftElbow, HumanBodyBones.LeftLowerArm },
{ (byte) MediaPipeKeypoint.RightElbow, HumanBodyBones.RightLowerArm },
{ (byte) MediaPipeKeypoint.LeftWrist, HumanBodyBones.LeftHand },
{ (byte) MediaPipeKeypoint.RightWrist, HumanBodyBones.RightHand },
{ (byte) MediaPipeKeypoint.LeftHip, HumanBodyBones.LeftUpperLeg },
{ (byte) MediaPipeKeypoint.RightHip, HumanBodyBones.RightUpperLeg },
{ (byte) MediaPipeKeypoint.LeftKnee, HumanBodyBones.LeftLowerLeg },
{ (byte) MediaPipeKeypoint.RightKnee, HumanBodyBones.RightLowerLeg },
{ (byte) MediaPipeKeypoint.LeftAnkle, HumanBodyBones.LeftFoot },
{ (byte) MediaPipeKeypoint.RightAnkle, HumanBodyBones.RightFoot }
};
public override bool IsRightSideJoint(byte joint) =>
joint is
(byte)MediaPipeKeypoint.RightShoulder or
(byte)MediaPipeKeypoint.RightElbow or
(byte)MediaPipeKeypoint.RightWrist or
(byte)MediaPipeKeypoint.RightHip or
(byte)MediaPipeKeypoint.RightKnee or
(byte)MediaPipeKeypoint.RightAnkle;
public override bool IsLeftSideJoint(byte joint)
=> joint is
(byte)MediaPipeKeypoint.LeftShoulder or
(byte)MediaPipeKeypoint.LeftElbow or
(byte)MediaPipeKeypoint.LeftWrist or
(byte)MediaPipeKeypoint.LeftHip or
(byte)MediaPipeKeypoint.LeftKnee or
(byte)MediaPipeKeypoint.LeftAnkle;
public Dictionary<string, (byte, byte)> GenerateBonesArray() =>
new ()
{
{ “RightUpperLeg”, ((byte)MediaPipeKeypoint.RightHip, (byte)MediaPipeKeypoint.RightKnee) },
{ “RightLowerLeg”, ((byte)MediaPipeKeypoint.RightKnee, (byte)MediaPipeKeypoint.RightAnkle) },
{ “LeftUpperLeg”, ((byte)MediaPipeKeypoint.LeftHip, (byte)MediaPipeKeypoint.LeftKnee) },
{ “LeftLowerLeg”, ((byte)MediaPipeKeypoint.LeftKnee, (byte)MediaPipeKeypoint.LeftAnkle) },
{ “RightUpperArm”, ((byte)MediaPipeKeypoint.RightShoulder, (byte)MediaPipeKeypoint.RightElbow) },
{ “RightLowerArm”, ((byte)MediaPipeKeypoint.RightElbow, (byte)MediaPipeKeypoint.RightWrist) },
{ “LeftUpperArm”, ((byte)MediaPipeKeypoint.LeftShoulder, (byte)MediaPipeKeypoint.LeftElbow) },
{ “LeftLowerArm”, ((byte)MediaPipeKeypoint.LeftElbow, (byte)MediaPipeKeypoint.LeftWrist) }
};
}