Pratyush101 commited on
Commit
150c323
·
verified ·
1 Parent(s): 3fca22e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -148,11 +148,15 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
148
  for button in buttonList:
149
  x, y = button.pos
150
  bw, bh = button.size
 
 
151
  if x < x8 < x + bw and y < y8 < y + bh:
 
152
  cv2.rectangle(img, (x, y), (x + bw, y + bh), color, -1, cv2.LINE_AA)
153
  cv2.putText(img, button.text, (x + int(0.2 * bw), y + int(0.7 * bh)), cv2.FONT_HERSHEY_PLAIN, font_scale, text_color, font_thickness)
154
-
155
  if distance < click_threshold:
 
156
  cv2.rectangle(img, (x, y), (x + bw, y + bh), color, -1, cv2.LINE_AA)
157
  cv2.putText(img, button.text, (x + int(0.2 * bw), y + int(0.7 * bh)), cv2.FONT_HERSHEY_PLAIN, font_scale, text_color, font_thickness)
158
  if time.time() - prev_key_time[0] > 2:
 
148
  for button in buttonList:
149
  x, y = button.pos
150
  bw, bh = button.size
151
+ button.is_hover=False
152
+ button.is_pressed=False
153
  if x < x8 < x + bw and y < y8 < y + bh:
154
+ button.is_hover = True
155
  cv2.rectangle(img, (x, y), (x + bw, y + bh), color, -1, cv2.LINE_AA)
156
  cv2.putText(img, button.text, (x + int(0.2 * bw), y + int(0.7 * bh)), cv2.FONT_HERSHEY_PLAIN, font_scale, text_color, font_thickness)
157
+
158
  if distance < click_threshold:
159
+ button.is_pressed = True # Mark as pressed
160
  cv2.rectangle(img, (x, y), (x + bw, y + bh), color, -1, cv2.LINE_AA)
161
  cv2.putText(img, button.text, (x + int(0.2 * bw), y + int(0.7 * bh)), cv2.FONT_HERSHEY_PLAIN, font_scale, text_color, font_thickness)
162
  if time.time() - prev_key_time[0] > 2: