-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.py
More file actions
59 lines (47 loc) · 2.18 KB
/
interface.py
File metadata and controls
59 lines (47 loc) · 2.18 KB
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
import cv2
import numpy as np
class Interface:
"""
Handles the visual presentation of the gesture interface.
"""
def __init__(self):
self.color_primary = (255, 255, 0) # Cyan/Teal
self.color_secondary = (255, 0, 255) # Magenta
self.color_alert = (0, 0, 255) # Red
self.font = cv2.FONT_HERSHEY_SIMPLEX
def draw_overlay(self, img, fps, mode, gesture_name, fingers=None):
h, w, c = img.shape
# 1. Futuristic Corners
length = 40
thickness = 2
color = self.color_primary
# Top Left
cv2.line(img, (0, 0), (length, 0), color, thickness)
cv2.line(img, (0, 0), (0, length), color, thickness)
# Top Right
cv2.line(img, (w, 0), (w - length, 0), color, thickness)
cv2.line(img, (w, 0), (w, length), color, thickness)
# Bottom Left
cv2.line(img, (0, h), (length, h), color, thickness)
cv2.line(img, (0, h), (0, h - length), color, thickness)
# Bottom Right
cv2.line(img, (w, h), (w - length, h), color, thickness)
cv2.line(img, (w, h), (w, h - length), color, thickness)
# 2. Status Bar (Bottom)
# Gradient-like effect using rectangle
overlay = img.copy()
cv2.rectangle(overlay, (0, h - 60), (w, h), (0, 0, 0), cv2.FILLED)
cv2.addWeighted(overlay, 0.6, img, 0.4, 0, img)
# 3. Text Info
cv2.putText(img, f"FPS: {int(fps)}", (20, h - 20), self.font, 0.7, (255, 255, 255), 2)
cv2.putText(img, f"MODE: {mode}", (w // 2 - 50, h - 20), self.font, 0.7, self.color_secondary, 2)
cv2.putText(img, f"GESTURE: {gesture_name}", (w - 250, h - 20), self.font, 0.7, self.color_primary, 2)
# 4. Debug Info (Top Center)
if fingers:
finger_str = str(fingers)
cv2.putText(img, f"Fingers: {finger_str}", (w // 2 - 100, 30), self.font, 0.6, (0, 255, 0), 2)
return img
def draw_hand_connections(self, img, lm_list):
# Custom drawing can go here if we want to override MediaPipe's default
# For now, MediaPipe's default is okay, but we could add glowing lines
pass