arshtech commited on
Commit
25881c9
·
verified ·
1 Parent(s): 94bfef5

Create gesture_recognizer.py

Browse files
Files changed (1) hide show
  1. gesture_recognizer.py +19 -0
gesture_recognizer.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ from hand_tracker import hands
3
+ from gesture_logic import get_finger_states
4
+ from gesture_matcher import match_gesture
5
+ from gesture_loader import load_gestures
6
+
7
+ gesture_rules = load_gestures()
8
+
9
+ def recognize_gesture(frame):
10
+ rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
11
+ results = hands.process(rgb)
12
+
13
+ if results.multi_hand_landmarks:
14
+ for hand_landmarks in results.multi_hand_landmarks:
15
+ finger_states = get_finger_states(hand_landmarks)
16
+ gesture = match_gesture(finger_states, gesture_rules)
17
+ return gesture
18
+
19
+ return None