Ivan Felipe Rodriguez commited on
Commit
3a45e37
1 Parent(s): d0ad6b9

fixing skip

Browse files
Files changed (1) hide show
  1. app.py +24 -27
app.py CHANGED
@@ -215,38 +215,35 @@ def process_video(input_video, out_fps = 'auto', skip_frames = 5):
215
 
216
  frame = cv2.resize(frame, (int(width), int(height)))
217
  print('starting Frame: ', cnt)
218
- if cnt*skip_frames %2==0:
219
-
220
- # flip frame vertically
221
- display_frame, result = inference_frame_serial(frame)
222
-
223
- #print(result)
224
- top_pred = process_results_for_plot(predictions = result.numpy(),
225
- classes = classes,
226
- class_sizes = class_sizes_lower)
227
-
228
- # add to last 5
229
- last_5_shark_detected[drawn_count % 5] = int(top_pred['shark_n'] > 0)
230
- last_5_human_detected[drawn_count % 5] = int(top_pred['human_n'] > 0)
231
- last_5_dangerous_dist[drawn_count % 5] = int(top_pred['dangerous_dist'] > 0)
232
-
233
- top_pred['shark_sighted'] = int(np.sum(last_5_shark_detected) > 3)
234
- top_pred['human_sighted'] = int(np.sum(last_5_human_detected) > 3)
235
- top_pred['dangerous_dist_confirmed'] = int(np.sum(last_5_dangerous_dist) > 3)
236
-
237
- frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
238
- prediction_frame = cv2.cvtColor(display_frame, cv2.COLOR_BGR2RGB)
239
-
240
- #
241
- #video.write(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR))
242
-
243
 
 
 
 
 
244
  prediction_frame = cv2.resize(prediction_frame, (int(width), int(height)))
245
  frame = prediction_frame
246
- frame = draw_cockpit(frame, top_pred,cnt*skip_frames)
247
 
248
  #if top_pred['shark_sighted'] or top_pred['shark_suspected']:
249
-
250
 
251
 
252
  frame = cv2.resize(frame, (int(width), int(height)))
 
215
 
216
  frame = cv2.resize(frame, (int(width), int(height)))
217
  print('starting Frame: ', cnt)
218
+ # flip frame vertically
219
+ display_frame, result = inference_frame_serial(frame)
220
+
221
+ #print(result)
222
+ top_pred = process_results_for_plot(predictions = result.numpy(),
223
+ classes = classes,
224
+ class_sizes = class_sizes_lower)
225
+
226
+ # add to last 5
227
+ last_5_shark_detected[drawn_count % 5] = int(top_pred['shark_n'] > 0)
228
+ last_5_human_detected[drawn_count % 5] = int(top_pred['human_n'] > 0)
229
+ last_5_dangerous_dist[drawn_count % 5] = int(top_pred['dangerous_dist'] > 0)
230
+
231
+ top_pred['shark_sighted'] = int(np.sum(last_5_shark_detected) > 3)
232
+ top_pred['human_sighted'] = int(np.sum(last_5_human_detected) > 3)
233
+ top_pred['dangerous_dist_confirmed'] = int(np.sum(last_5_dangerous_dist) > 3)
234
+
235
+ frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
236
+ prediction_frame = cv2.cvtColor(display_frame, cv2.COLOR_BGR2RGB)
 
 
 
 
 
 
237
 
238
+ #
239
+ #video.write(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR))
240
+
241
+ if cnt*skip_frames %2==0:
242
  prediction_frame = cv2.resize(prediction_frame, (int(width), int(height)))
243
  frame = prediction_frame
 
244
 
245
  #if top_pred['shark_sighted'] or top_pred['shark_suspected']:
246
+ frame = draw_cockpit(frame, top_pred,cnt*skip_frames)
247
 
248
 
249
  frame = cv2.resize(frame, (int(width), int(height)))