Pratyush101 commited on
Commit
380ff5f
·
verified ·
1 Parent(s): ebc9760

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -60,8 +60,6 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
60
  # Create the keyboard buttons
61
  buttonList = []
62
  h, w = img.shape[:2]
63
- st.write(w)
64
- st.write(h)
65
  key_width = int(0.08 * w)
66
  key_height = int(0.1 * h)
67
  font_scale = 0.005 * w
@@ -118,17 +116,18 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
118
  cv2.putText(img, button.text, (x + int(0.2 * bw), y + int(0.7 * bh)), cv2.FONT_HERSHEY_PLAIN, font_scale, (255, 255, 255), font_thickness)
119
  if button.text != 'BS' and button.text != 'SPACE':
120
  output_text += button.text # Append key to output text
121
- # # Handle button press
122
- if (distance / np.sqrt(bbox[2] ** 2 + bbox[3] ** 2)) * 100<click_threshold:
123
- if time.time() - prev_key_time[0] > 2:
124
- prev_key_time[0] = time.time()
125
- if button.text != 'BS' and button.text != 'SPACE':
126
- output_text += button.text # Append key to output text
127
- elif button.text == 'BS':
128
- output_text = output_text[:-1] # Remove last character
129
- else:
130
- output_text += ' ' # Add space
131
- cv2.putText(img, output_text, (int(0.05 * w) , int(0.95 * h)), cv2.FONT_HERSHEY_PLAIN, 5, (255, 255, 255), 5)
 
132
 
133
 
134
 
 
60
  # Create the keyboard buttons
61
  buttonList = []
62
  h, w = img.shape[:2]
 
 
63
  key_width = int(0.08 * w)
64
  key_height = int(0.1 * h)
65
  font_scale = 0.005 * w
 
116
  cv2.putText(img, button.text, (x + int(0.2 * bw), y + int(0.7 * bh)), cv2.FONT_HERSHEY_PLAIN, font_scale, (255, 255, 255), font_thickness)
117
  if button.text != 'BS' and button.text != 'SPACE':
118
  output_text += button.text # Append key to output text
119
+ # # # Handle button press
120
+ # if (distance / np.sqrt(bbox[2] ** 2 + bbox[3] ** 2)) * 100<click_threshold:
121
+ cv2.putText(img, (distance / np.sqrt(bbox[2] ** 2 + bbox[3] ** 2)), (int(0.05 * w) , int(0.95 * h)), cv2.FONT_HERSHEY_PLAIN, 5, (255, 255, 255), 5)
122
+ # if time.time() - prev_key_time[0] > 2:
123
+ # prev_key_time[0] = time.time()
124
+ # if button.text != 'BS' and button.text != 'SPACE':
125
+ # output_text += button.text # Append key to output text
126
+ # elif button.text == 'BS':
127
+ # output_text = output_text[:-1] # Remove last character
128
+ # else:
129
+ # output_text += ' ' # Add space
130
+ # cv2.putText(img, output_text, (int(0.05 * w) , int(0.95 * h)), cv2.FONT_HERSHEY_PLAIN, 5, (255, 255, 255), 5)
131
 
132
 
133