pub const SKELETON: [[usize; 2]; 19] = [
[15, 13],
[13, 11],
[16, 14],
[14, 12],
[11, 12],
[5, 11],
[6, 12],
[5, 6],
[5, 7],
[6, 8],
[7, 9],
[8, 10],
[1, 2],
[0, 1],
[0, 2],
[1, 3],
[2, 4],
[3, 5],
[4, 6],
];
pub const LIMB_COLOR_INDICES: [usize; 19] = [
0, 0, 0, 0, 7, 7, 7, 9, 9, 9, 9, 9, 16, 16, 16, 16, 16, 16, 16,
];
pub const KPT_COLOR_INDICES: [usize; 17] = [16, 16, 16, 16, 16, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0];
#[cfg(test)]
mod tests {
use super::*;
const NUM_KEYPOINTS: usize = 17;
#[test]
fn test_skeleton_indices_in_range() {
for pair in SKELETON {
for &idx in &pair {
assert!(idx < NUM_KEYPOINTS, "skeleton index {idx} out of range");
}
assert_ne!(
pair[0], pair[1],
"skeleton bone connects a keypoint to itself"
);
}
}
#[test]
fn test_palette_lengths_match_spec() {
assert_eq!(SKELETON.len(), LIMB_COLOR_INDICES.len());
assert_eq!(KPT_COLOR_INDICES.len(), NUM_KEYPOINTS);
}
#[test]
fn test_color_indices_within_pose_palette() {
const POSE_PALETTE_LEN: usize = 20;
for &c in &LIMB_COLOR_INDICES {
assert!(c < POSE_PALETTE_LEN, "limb color index {c} out of palette");
}
for &c in &KPT_COLOR_INDICES {
assert!(c < POSE_PALETTE_LEN, "kpt color index {c} out of palette");
}
}
}