fix holistic tracking with singular feature types

This commit is contained in:
Jules Youngberg 2022-06-20 22:15:01 -07:00
parent c470510a19
commit f405c764b9
6 changed files with 20 additions and 10 deletions

2
.gitignore vendored
View File

@ -9,4 +9,4 @@ Cargo.lock
# These are backup files generated by rustfmt # These are backup files generated by rustfmt
**/*.rs.bk **/*.rs.bk
/refs/ /refs/
mediapipe /mediapipe/

View File

@ -16,7 +16,7 @@ fn face_mesh() -> Result<()> {
cap.set(videoio::CAP_PROP_FRAME_HEIGHT, 480.0)?; cap.set(videoio::CAP_PROP_FRAME_HEIGHT, 480.0)?;
cap.set(videoio::CAP_PROP_FPS, 30.0)?; cap.set(videoio::CAP_PROP_FPS, 30.0)?;
let mut detector = face_mesh::HolisticDetector::default(); let mut detector = holistic::HolisticDetector::default();
let mut raw_frame = Mat::default(); let mut raw_frame = Mat::default();
let mut rgb_frame = Mat::default(); let mut rgb_frame = Mat::default();

1
mediapipe Symbolic link
View File

@ -0,0 +1 @@
../mediapipe/mediapipe

View File

@ -72,9 +72,12 @@ fn bindgen_test_layout_mediagraph_Landmark() {
) )
); );
} }
pub const mediagraph_FeatureType_POSE: mediagraph_FeatureType = 0; pub const mediagraph_FeatureType_FACE: mediagraph_FeatureType = 0;
pub const mediagraph_FeatureType_HANDS: mediagraph_FeatureType = 1; pub const mediagraph_FeatureType_FACES: mediagraph_FeatureType = 1;
pub const mediagraph_FeatureType_FACE: mediagraph_FeatureType = 2; pub const mediagraph_FeatureType_HAND: mediagraph_FeatureType = 2;
pub const mediagraph_FeatureType_HANDS: mediagraph_FeatureType = 3;
pub const mediagraph_FeatureType_POSE: mediagraph_FeatureType = 4;
pub const mediagraph_FeatureType_POSES: mediagraph_FeatureType = 5;
pub type mediagraph_FeatureType = ::std::os::raw::c_uint; pub type mediagraph_FeatureType = ::std::os::raw::c_uint;
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]

View File

@ -10,19 +10,19 @@ impl HolisticDetector {
let outputs = vec![ let outputs = vec![
Output { Output {
type_: FeatureType::Pose, type_: FeatureType::Pose,
name: "pose_landmarks", name: "pose_landmarks".into(),
}, },
Output { Output {
type_: FeatureType::Face, type_: FeatureType::Face,
name: "face_landmarks", name: "face_landmarks".into(),
}, },
Output { Output {
type_: FeatureType::Hand, type_: FeatureType::Hand,
name: "left_hand_landmarks", name: "left_hand_landmarks".into(),
}, },
Output { Output {
type_: FeatureType::Hand, type_: FeatureType::Hand,
name: "right_hand_landmarks", name: "right_hand_landmarks".into(),
}, },
]; ];

View File

@ -30,18 +30,22 @@ type mOutput = mediagraph_Output;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub enum FeatureType { pub enum FeatureType {
Face, Face,
Faces,
Hand, Hand,
Hands, Hands,
Pose, Pose,
Poses,
} }
impl FeatureType { impl FeatureType {
fn num_landmarks(&self) -> usize { fn num_landmarks(&self) -> usize {
match self { match self {
FeatureType::Face => 478, FeatureType::Face => 478,
FeatureType::Faces => 478,
FeatureType::Hand => 21, FeatureType::Hand => 21,
FeatureType::Hands => 42, FeatureType::Hands => 42,
FeatureType::Pose => 33, FeatureType::Pose => 33,
FeatureType::Poses => 33,
} }
} }
} }
@ -50,9 +54,11 @@ impl Into<mFeatureType> for FeatureType {
fn into(self) -> mFeatureType { fn into(self) -> mFeatureType {
match self { match self {
FeatureType::Face => mediagraph_FeatureType_FACE, FeatureType::Face => mediagraph_FeatureType_FACE,
FeatureType::Hand => mediagraph_FeatureType_HANDS, FeatureType::Faces => mediagraph_FeatureType_FACES,
FeatureType::Hand => mediagraph_FeatureType_HAND,
FeatureType::Hands => mediagraph_FeatureType_HANDS, FeatureType::Hands => mediagraph_FeatureType_HANDS,
FeatureType::Pose => mediagraph_FeatureType_POSE, FeatureType::Pose => mediagraph_FeatureType_POSE,
FeatureType::Poses => mediagraph_FeatureType_POSES,
} }
} }
} }