Pratyush101 commited on
Commit
6cb30be
·
verified ·
1 Parent(s): 8b93117

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -115,17 +115,19 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
115
  cv2.rectangle(img, (x, y), (x + bw, y + bh), (0, 255, 160), -1)
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
 
118
- # Handle button press
119
- if (distance / np.sqrt(bbox[2] ** 2 + bbox[3] ** 2)) * 100 < click_threshold:
120
- if time.time() - prev_key_time[0] > 2:
121
- prev_key_time[0] = time.time()
122
- if button.text != 'BS' and button.text != 'SPACE':
123
- st.session_state["output_text"] += button.text # Append key to output text
124
- cv2.rectangle(img, (0, 0), (10, 10), (0, 0, 0), -1) #it is a testing box
125
- elif button.text == 'BS':
126
- st.session_state["output_text"] = st.session_state["output_text"][:-1] # Remove last character
127
- else:
128
- st.session_state["output_text"] += ' ' # Add space
 
 
129
 
130
  result_queue.put(detections)
131
 
 
115
  cv2.rectangle(img, (x, y), (x + bw, y + bh), (0, 255, 160), -1)
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
 
118
+ # # Handle button press
119
+ # if (distance / np.sqrt(bbox[2] ** 2 + bbox[3] ** 2)) * 100 < click_threshold:
120
+ # if time.time() - prev_key_time[0] > 2:
121
+ # prev_key_time[0] = time.time()
122
+ # if button.text != 'BS' and button.text != 'SPACE':
123
+ # st.session_state["output_text"] += button.text # Append key to output text
124
+ # elif button.text == 'BS':
125
+ # st.session_state["output_text"] = st.session_state["output_text"][:-1] # Remove last character
126
+ # else:
127
+ # st.session_state["output_text"] += ' ' # Add space
128
+ if distance<30:
129
+ st.session_state["output_text"] += button.text
130
+
131
 
132
  result_queue.put(detections)
133