File size: 3,656 Bytes
95db528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
afecd35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95db528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from pydantic import BaseModel
from typing import List, Optional


class Gesture(BaseModel):
    """Represents a detected gesture with metadata."""
    gesture: str
    duration: int  # Duration in frames
    confidence: float


class GestureResponse(BaseModel):
    """Response model containing a list of detected gestures."""
    gestures: List[Gesture]


# Primary gesture mappings for the main gestures + additional ones
GESTURE_MAPPING = {
    # Original 5 main gestures
    27: "thumbs_up",       # like
    31: "palm",            # open palm wave (5 fingers)
    32: "peace",           # peace sign (2 fingers)
    29: "ok",              # OK sign
    20: "call",            # call me (little finger)
    
    # Finger counting (1-5)
    30: "one",             # 1 finger
    39: "two_up",          # 2 fingers (peace sign)
    37: "three",           # 3 fingers
    26: "four",            # 4 fingers
    # Note: 5 fingers is same as palm (31)
    
    # Surprise gesture
    23: "middle_finger",   # middle finger (surprise!)
    
    # Additional useful gestures
    25: "fist",            # closed fist
    19: "point",           # pointing with index finger
    35: "stop",            # stop gesture
}

# Production gesture mapping with clean, consistent names
# Hand-agnostic counting (left/right variations map to same gesture)
PRODUCTION_GESTURE_MAPPING = {
    # Counting gestures (1-5) - hand agnostic
    30: "one",             # 1 finger (any direction)
    42: "one",             # 1 finger left (maps to "one")
    43: "one",             # 1 finger right (maps to "one")
    44: "one",             # 1 finger down (maps to "one")
    
    32: "two",             # 2 fingers (peace sign)
    39: "two",             # 2 fingers up (maps to "two")
    14: "two",             # 2 fingers left (maps to "two")
    15: "two",             # 2 fingers right (maps to "two")
    16: "two",             # 2 fingers down (maps to "two")
    
    37: "three",           # 3 fingers (any direction)
    21: "three",           # 3 fingers variant (maps to "three")
    38: "three",           # 3 fingers variant 2 (maps to "three")
    
    26: "four",            # 4 fingers
    
    31: "five",            # 5 fingers (open palm)
    
    # Extra gestures for production
    27: "thumbs_up",       # thumbs up gesture
    23: "middle_finger",   # middle finger
    33: "peace_inverted",  # peace sign inverted
    
    # Additional useful gestures
    29: "ok",              # OK sign
    20: "call",            # call me gesture
    25: "fist",            # closed fist
    19: "point",           # pointing
    35: "stop",            # stop gesture
}

# Additional gesture mappings for completeness (all raw model outputs)
FULL_GESTURE_MAPPING = {
    0: "hand_down",
    1: "hand_right", 
    2: "hand_left",
    3: "thumb_index",
    4: "thumb_left",
    5: "thumb_right",
    6: "thumb_down",
    7: "half_up",
    8: "half_left",
    9: "half_right",
    10: "half_down",
    11: "part_hand_heart",
    12: "part_hand_heart2",
    13: "fist_inverted",
    14: "two_left",
    15: "two_right",
    16: "two_down",
    17: "grabbing",
    18: "grip",
    19: "point",
    20: "call",
    21: "three3",
    22: "little_finger",
    23: "middle_finger",
    24: "dislike",
    25: "fist",
    26: "four",
    27: "like",
    28: "mute",
    29: "ok",
    30: "one",
    31: "palm",
    32: "peace",
    33: "peace_inverted",
    34: "rock",
    35: "stop",
    36: "stop_inverted",
    37: "three",
    38: "three2",
    39: "two_up",
    40: "two_up_inverted",
    41: "three_gun",
    42: "one_left",
    43: "one_right",
    44: "one_down"
}