void calculateBoneLengths() { // Posiitons are in the lsp order. int[] boneJoints = new int[] { // 14 means hip 2, 3, 2, 1, 1, 0, 3, 4, 4, 5, 14, 12, 12, 8, 8, 7, 7, 6, 12, 9, 9, 10, 10, 11, 12, 13, }; var positions = Positions.ToList(); var hip = (positions[2] + positions[3]) * 0.5f; positions.Add(hip); for (int i = 0; i < 13; i++) { int src = boneJoints[2 * i]; int dst = boneJoints[2 * i + 1]; var translate = positions[src] - positions[dst]; var boneLength = translate.magnitude; BoneLengths.Add(boneLength); } }
public void CalculateBoneLengths() { // Positions of human joint keypoints are in the MPII order int[] boneJoints = new int[] { // 15 human bones in total and 6 means pelvis(hip) 6, 2, // rightHipBone 2, 1, // rightThigh 1, 0, // rightCalf 6, 3, // leftHipBone 3, 4, // leftThigh 4, 5, // leftCalf 6, 7, // waist 7, 8, // chest 8, 9, // neck 8, 12, // rightClavicle 12, 11, // rightUpperArm 11, 10, // rightForearm 8, 13, // leftClavicle 13, 14, // leftUpperArm 14, 15, // leftForearm }; var positions = Positions.ToList(); for (int i = 0; i < 15; i++) { int src = boneJoints[2 * i]; int dst = boneJoints[2 * i + 1]; var translate = positions[dst] - positions[src]; // vector points to dst from src var boneLength = translate.magnitude; BoneLengths.Add(boneLength); } }