qualia_vision/biosense/liveness/
challenge_kind.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4#[repr(u8)]
5pub enum ChallengeKind {
6 YawLeft = 1,
7 YawRight = 2,
8 Smile = 3,
9 BlinkTwice = 4,
10 OpenMouth = 5,
12 PitchUp = 6,
14 PitchDown = 7,
16}
17
18impl ChallengeKind {
19 pub const ALL: [ChallengeKind; 7] = [
20 Self::YawLeft,
21 Self::YawRight,
22 Self::Smile,
23 Self::BlinkTwice,
24 Self::OpenMouth,
25 Self::PitchUp,
26 Self::PitchDown,
27 ];
28
29 pub const ROTATION: [ChallengeKind; 4] = [
31 Self::YawLeft,
32 Self::YawRight,
33 Self::PitchUp,
34 Self::PitchDown,
35 ];
36
37 pub const fn as_str(self) -> &'static str {
39 match self {
40 Self::YawLeft => "yaw_left",
41 Self::YawRight => "yaw_right",
42 Self::Smile => "smile",
43 Self::BlinkTwice => "blink_2",
44 Self::OpenMouth => "open_mouth",
45 Self::PitchUp => "pitch_up",
46 Self::PitchDown => "pitch_down",
47 }
48 }
49
50 pub const fn is_rotation(self) -> bool {
52 matches!(
53 self,
54 Self::YawLeft | Self::YawRight | Self::PitchUp | Self::PitchDown
55 )
56 }
57
58 pub fn from_seed(seed: u64) -> Self {
60 Self::ALL[(seed as usize) % Self::ALL.len()]
61 }
62
63 pub fn from_seed_prefer_rotation(seed: u64) -> Self {
65 Self::ROTATION[(seed as usize) % Self::ROTATION.len()]
66 }
67}