Pratyush101 commited on
Commit
ce6ce22
·
verified ·
1 Parent(s): 8ce3260

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -35,9 +35,6 @@ class Button:
35
  self.pos = pos
36
  self.size = size
37
  self.text = text
38
- # Draw button text on the keyboard canvas
39
- cv2.putText(img, self.text, (self.pos[0]+20, self.pos[1]+70),
40
- cv2.FONT_HERSHEY_PLAIN, 5, (255, 255, 255), 3)
41
 
42
  class Detection(NamedTuple):
43
  label: str
@@ -78,6 +75,13 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
78
  buttonList.append(Button([90 + 10 * 100, 30], 'BS', size=[125, 100]))
79
  buttonList.append(Button([300, 370], 'SPACE', size=[500, 100]))
80
 
 
 
 
 
 
 
 
81
  detections = []
82
  if result.multi_hand_landmarks:
83
  for hand_landmarks in result.multi_hand_landmarks:
@@ -104,13 +108,13 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
104
  x4, y4 = int(hand_landmarks.landmark[mp_hands.HandLandmark.THUMB_TIP].x * w), int(hand_landmarks.landmark[mp_hands.HandLandmark.THUMB_TIP].y * h)
105
  x8, y8 = int(hand_landmarks.landmark[mp_hands.HandLandmark.INDEX_FINGER_TIP].x * w), int(hand_landmarks.landmark[mp_hands.HandLandmark.INDEX_FINGER_TIP].y * h)
106
 
107
- # Check for key presses
108
- for button in buttonList:
109
- x, y = button.pos
110
- w, h = button.size
111
- if x < x8 < x + w and y < y8 < y + h:
112
- cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 160), -1)
113
- cv2.putText(img, button.text, (x + 20, y + 70), cv2.FONT_HERSHEY_PLAIN, 5, (255, 255, 255), 3)
114
 
115
 
116
 
 
35
  self.pos = pos
36
  self.size = size
37
  self.text = text
 
 
 
38
 
39
  class Detection(NamedTuple):
40
  label: str
 
75
  buttonList.append(Button([90 + 10 * 100, 30], 'BS', size=[125, 100]))
76
  buttonList.append(Button([300, 370], 'SPACE', size=[500, 100]))
77
 
78
+ # Draw Keyboard Buttons
79
+ for button in buttonList:
80
+ x, y = button.pos
81
+ w, h = button.size
82
+ cv2.rectangle(img, (x, y), (x + w, y + h), (200, 200, 200), -1)
83
+ cv2.putText(img, button.text, (x + 20, y + 70), cv2.FONT_HERSHEY_PLAIN, 5, (0, 0, 0), 3)
84
+
85
  detections = []
86
  if result.multi_hand_landmarks:
87
  for hand_landmarks in result.multi_hand_landmarks:
 
108
  x4, y4 = int(hand_landmarks.landmark[mp_hands.HandLandmark.THUMB_TIP].x * w), int(hand_landmarks.landmark[mp_hands.HandLandmark.THUMB_TIP].y * h)
109
  x8, y8 = int(hand_landmarks.landmark[mp_hands.HandLandmark.INDEX_FINGER_TIP].x * w), int(hand_landmarks.landmark[mp_hands.HandLandmark.INDEX_FINGER_TIP].y * h)
110
 
111
+ # # Check for key presses
112
+ # for button in buttonList:
113
+ # x, y = button.pos
114
+ # w, h = button.size
115
+ # if x < x8 < x + w and y < y8 < y + h:
116
+ # cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 160), -1)
117
+ # cv2.putText(img, button.text, (x + 20, y + 70), cv2.FONT_HERSHEY_PLAIN, 5, (255, 255, 255), 3)
118
 
119
 
120