stupidog04 commited on
Commit
22849cc
·
1 Parent(s): c139569

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -64,21 +64,19 @@ def inference(video, lang, time_step):
64
  while success:
65
  if count % (int(frame_rate * time_step)) == 0:
66
  for i, box in enumerate(largest_boxes):
67
- bbox_pos = box_position(box)
68
- if np.linalg.norm(np.array(bbox_pos) - np.array(positions[i])) < 50:
69
- x1, y1 = box[0][0]
70
- x2, y2 = box[0][2]
71
- box_width = x2 - x1
72
- box_height = y2 - y1
73
- ratio = 0.2
74
- x1 = max(0, int(x1 - ratio * box_width))
75
- x2 = min(frame.shape[1], int(x2 + ratio * box_width))
76
- y1 = max(0, int(y1 - ratio * box_height))
77
- y2 = min(frame.shape[0], int(y2 + ratio * box_height))
78
- cropped_frame = frame[y1:y2, x1:x2]
79
- text = reader.readtext(cropped_frame)
80
- if text:
81
- temporal_profiles[i].append((count / frame_rate, text[0][1]))
82
  im = PIL.Image.fromarray(frame)
83
  im_with_boxes = draw_boxes(im, bounds)
84
  output_frames.append(np.array(im_with_boxes))
 
64
  while success:
65
  if count % (int(frame_rate * time_step)) == 0:
66
  for i, box in enumerate(largest_boxes):
67
+ x1, y1 = box[0][0]
68
+ x2, y2 = box[0][2]
69
+ box_width = x2 - x1
70
+ box_height = y2 - y1
71
+ ratio = 0.2
72
+ x1 = max(0, int(x1 - ratio * box_width))
73
+ x2 = min(frame.shape[1], int(x2 + ratio * box_width))
74
+ y1 = max(0, int(y1 - ratio * box_height))
75
+ y2 = min(frame.shape[0], int(y2 + ratio * box_height))
76
+ cropped_frame = frame[y1:y2, x1:x2]
77
+ text = reader.readtext(cropped_frame)
78
+ if text:
79
+ temporal_profiles[i].append((count / frame_rate, text[0][1]))
 
 
80
  im = PIL.Image.fromarray(frame)
81
  im_with_boxes = draw_boxes(im, bounds)
82
  output_frames.append(np.array(im_with_boxes))