Pratyush101 commited on
Commit
50db096
·
verified ·
1 Parent(s): f431172

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -59,8 +59,8 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
59
  # Create the keyboard buttons
60
  buttonList = []
61
  h, w = img.shape[:2]
62
- key_width = int(0.08 * w)
63
- key_height = int(0.1 * h)
64
  font_scale = 0.005 * w
65
  font_thickness = int(0.01 * h)
66
 
@@ -123,7 +123,18 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
123
  output_text = output_text[:-1] # Remove last character
124
  else:
125
  output_text += ' ' # Add space
126
- cv2.putText(img, output_text, (int(0.05 * w) , int(0.70 * h)), cv2.FONT_HERSHEY_PLAIN, 2, (0, 0, 0), 5)
 
 
 
 
 
 
 
 
 
 
 
127
 
128
 
129
 
 
59
  # Create the keyboard buttons
60
  buttonList = []
61
  h, w = img.shape[:2]
62
+ key_width = int(0.06 * w)
63
+ key_height = int(0.09 * h)
64
  font_scale = 0.005 * w
65
  font_thickness = int(0.01 * h)
66
 
 
123
  output_text = output_text[:-1] # Remove last character
124
  else:
125
  output_text += ' ' # Add space
126
+ # Position and dimensions for the rectangle
127
+ text_x = int(0.05 * w)
128
+ text_y = int(0.70 * h)
129
+ text_width = int(0.9 * w) # Adjust width as needed
130
+ text_height = int(0.1 * h) # Adjust height as needed
131
+ # Draw the rectangle
132
+ cv2.rectangle(img,
133
+ (text_x, text_y - text_height), # Top-left corner
134
+ (text_x + text_width, text_y), # Bottom-right corner
135
+ (0, 0, 0), # Background color (light gray)
136
+ -1) # Filled rectangle
137
+ cv2.putText(img, output_text, (int(0.05 * w) , int(0.70 * h)), cv2.FONT_HERSHEY_PLAIN, 2, (255, 255, 255), 5)
138
 
139
 
140