stupidog04 commited on
Commit
658f973
1 Parent(s): d3af935

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -61,9 +61,11 @@ def inference(video, lang, time_step, full_scan=False):
61
  temporal_profiles = [[] for _ in range(len(largest_boxes))]
62
 
63
  # Match bboxes to position and store the text read by OCR
64
- while success:
65
- if count % (int(frame_rate * time_step)) == 0:
66
- if full_scan:
 
 
67
  bounds = reader.readtext(frame)
68
  for box in bounds:
69
  bbox_pos = box_position(box)
@@ -72,7 +74,15 @@ def inference(video, lang, time_step, full_scan=False):
72
  if distance < 50:
73
  temporal_profiles[i].append((count / frame_rate, box[1]))
74
  break
75
- else:
 
 
 
 
 
 
 
 
76
  for i, box in enumerate(largest_boxes):
77
  x1, y1 = box[0][0]
78
  x2, y2 = box[0][2]
@@ -87,13 +97,11 @@ def inference(video, lang, time_step, full_scan=False):
87
  text = reader.readtext(cropped_frame)
88
  if text:
89
  temporal_profiles[i].append((count / frame_rate, text[0][1]))
90
-
91
- im = PIL.Image.fromarray(frame)
92
- im_with_boxes = draw_boxes(im, bounds)
93
- output_frames.append(np.array(im_with_boxes))
94
-
95
- success, frame = vidcap.read()
96
- count += 1
97
 
98
  # Default resolutions of the frame are obtained. The default resolutions are system dependent.
99
  # We convert the resolutions from float to integer.
 
61
  temporal_profiles = [[] for _ in range(len(largest_boxes))]
62
 
63
  # Match bboxes to position and store the text read by OCR
64
+ # Match bboxes to position and store the text read by OCR
65
+ if full_scan:
66
+ # Match bboxes to position and store the text read by OCR
67
+ while success:
68
+ if count % (int(frame_rate * time_step)) == 0:
69
  bounds = reader.readtext(frame)
70
  for box in bounds:
71
  bbox_pos = box_position(box)
 
74
  if distance < 50:
75
  temporal_profiles[i].append((count / frame_rate, box[1]))
76
  break
77
+ im = PIL.Image.fromarray(frame)
78
+ im_with_boxes = draw_boxes(im, bounds)
79
+ output_frames.append(np.array(im_with_boxes))
80
+ success, frame = vidcap.read()
81
+ count += 1
82
+ else:
83
+ # Match bboxes to position and store the text read by OCR
84
+ while success:
85
+ if count % (int(frame_rate * time_step)) == 0:
86
  for i, box in enumerate(largest_boxes):
87
  x1, y1 = box[0][0]
88
  x2, y2 = box[0][2]
 
97
  text = reader.readtext(cropped_frame)
98
  if text:
99
  temporal_profiles[i].append((count / frame_rate, text[0][1]))
100
+ im = PIL.Image.fromarray(frame)
101
+ im_with_boxes = draw_boxes(im, bounds)
102
+ output_frames.append(np.array(im_with_boxes))
103
+ success, frame = vidcap.read()
104
+ count += 1
 
 
105
 
106
  # Default resolutions of the frame are obtained. The default resolutions are system dependent.
107
  # We convert the resolutions from float to integer.