Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,7 @@ emotion_map = {
|
|
| 38 |
|
| 39 |
} #added in the basic emotions we'll have the ai read
|
| 40 |
|
| 41 |
-
mp_hands = mp.solutions.hands
|
| 42 |
hands = mp_hands.Hands(static_image_mode=True, max_num_hands=1) #mediapipe setting up
|
| 43 |
|
| 44 |
def detect_gesture(image):
|
|
@@ -47,10 +47,10 @@ def detect_gesture(image):
|
|
| 47 |
return None
|
| 48 |
|
| 49 |
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 50 |
-
results = hands.process(image_rgb)
|
| 51 |
|
| 52 |
if not results.multi_hand_landmarks:
|
| 53 |
-
return None
|
| 54 |
|
| 55 |
lm = results.multi_hand_landmarks[0].landmark
|
| 56 |
|
|
|
|
| 38 |
|
| 39 |
} #added in the basic emotions we'll have the ai read
|
| 40 |
|
| 41 |
+
mp_hands = mp.solutions.hands #ran into an error here
|
| 42 |
hands = mp_hands.Hands(static_image_mode=True, max_num_hands=1) #mediapipe setting up
|
| 43 |
|
| 44 |
def detect_gesture(image):
|
|
|
|
| 47 |
return None
|
| 48 |
|
| 49 |
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 50 |
+
results = hands.process(image_rgb) #sends image into ML model for hand landmark detection
|
| 51 |
|
| 52 |
if not results.multi_hand_landmarks:
|
| 53 |
+
return None #prevents crash when no hand is detected
|
| 54 |
|
| 55 |
lm = results.multi_hand_landmarks[0].landmark
|
| 56 |
|