Pratyush101 commited on
Commit
ba749b3
·
verified ·
1 Parent(s): bc91b1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -116,18 +116,17 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
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:
121
-
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
- # st.session_state["output_text"] += button.text # Append key to output text
126
- # elif button.text == 'BS':
127
- # st.session_state["output_text"] = st.session_state["output_text"][:-1] # Remove last character
128
- # else:
129
- # st.session_state["output_text"] += ' ' # Add space
130
- # Display typed text
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
 
 
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
+ if time.time() - prev_key_time[0] > 2:
122
+ prev_key_time[0] = time.time()
123
+ if button.text != 'BS' and button.text != 'SPACE':
124
+ output_text += button.text # Append key to output text
125
+ elif button.text == 'BS':
126
+ output_text = output_text[:-1] # Remove last character
127
+ else:
128
+ output_text += ' ' # Add space
129
+ Display typed text
 
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