simplify structs

This commit is contained in:
Jules Youngberg 2022-06-12 22:14:06 -07:00
parent 0a0ecbb93c
commit 50c8096906

View File

@ -173,28 +173,18 @@ pub mod pose {
} }
pub struct PoseDetector { pub struct PoseDetector {
pub mode: bool, // false
pub smooth: bool, // true,
pub detection_con: f32, // 0.5
pub track_con: f32, // 0.5
graph: Detector, graph: Detector,
} }
impl PoseDetector { impl PoseDetector {
pub fn new(mode: bool, smooth: bool, detection_con: f32, track_con: f32) -> Self { pub fn new() -> Self {
let graph = Detector::new( let graph = Detector::new(
POSE_GRAPH_TYPE, POSE_GRAPH_TYPE,
include_str!("pose_tracking_cpu.txt"), include_str!("pose_tracking_cpu.txt"),
"pose_landmarks", "pose_landmarks",
); );
Self { Self { graph }
mode,
smooth,
detection_con,
track_con,
graph,
}
} }
/// Processes the input frame, returns a pose if detected. /// Processes the input frame, returns a pose if detected.
@ -213,7 +203,7 @@ pub mod pose {
impl Default for PoseDetector { impl Default for PoseDetector {
fn default() -> Self { fn default() -> Self {
Self::new(false, true, 0.5, 0.5) Self::new()
} }
} }
} }
@ -223,33 +213,18 @@ pub mod face_mesh {
use super::*; use super::*;
pub struct FaceMeshDetector { pub struct FaceMeshDetector {
pub static_mode: bool, // false
pub max_faces: usize, // 2
pub min_detection_con: f32, // 0.5
pub min_track_con: f32, // 0.5
graph: Detector, graph: Detector,
} }
impl FaceMeshDetector { impl FaceMeshDetector {
pub fn new( pub fn new() -> Self {
static_mode: bool,
max_faces: usize,
min_detection_con: f32,
min_track_con: f32,
) -> Self {
let graph = Detector::new( let graph = Detector::new(
FACE_GRAPH_TYPE, FACE_GRAPH_TYPE,
include_str!("face_mesh_desktop_live.txt"), include_str!("face_mesh_desktop_live.txt"),
"multi_face_landmarks", "multi_face_landmarks",
); );
Self { Self { graph }
static_mode,
max_faces,
min_detection_con,
min_track_con,
graph,
}
} }
/// Processes the input frame, returns a face mesh if detected. /// Processes the input frame, returns a face mesh if detected.
@ -268,7 +243,7 @@ pub mod face_mesh {
impl Default for FaceMeshDetector { impl Default for FaceMeshDetector {
fn default() -> Self { fn default() -> Self {
Self::new(false, 2, 0.5, 0.5) Self::new()
} }
} }
} }
@ -303,28 +278,18 @@ pub mod hands {
} }
pub struct HandDetector { pub struct HandDetector {
pub mode: bool,
pub max_hands: usize,
pub detection_con: f32, // 0.5
pub min_track_con: f32, // 0.5
graph: Detector, graph: Detector,
} }
impl HandDetector { impl HandDetector {
pub fn new(mode: bool, max_hands: usize, detection_con: f32, min_track_con: f32) -> Self { pub fn new() -> Self {
let graph = Detector::new( let graph = Detector::new(
HANDS_GRAPH_TYPE, HANDS_GRAPH_TYPE,
include_str!("hand_tracking_desktop_live.txt"), include_str!("hand_tracking_desktop_live.txt"),
"hand_landmarks", "hand_landmarks",
); );
Self { Self { graph }
mode,
max_hands,
detection_con,
min_track_con,
graph,
}
} }
/// Processes the input frame, returns a tuple of hands if detected. /// Processes the input frame, returns a tuple of hands if detected.
@ -346,7 +311,7 @@ pub mod hands {
impl Default for HandDetector { impl Default for HandDetector {
fn default() -> Self { fn default() -> Self {
Self::new(false, 2, 0.5, 0.5) Self::new()
} }
} }
} }