DSatishchandra commited on
Commit
13928c5
Β·
verified Β·
1 Parent(s): 26831a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -62,12 +62,12 @@ def live_feed_generator(video_type, confidence_threshold=0.9):
62
 
63
  while cap.isOpened():
64
  ret, frame = cap.read()
65
- if not ret:
66
- print(f"Failed to read frame at count {state.frame_count}")
67
  cap.set(cv2.CAP_PROP_POS_FRAMES, 0) # Loop the video
68
  continue
69
  else:
70
- print(f"Failed to read frame at count {state.frame_count}")
71
 
72
  state.frame_count += 1
73
  frame_pil = video_service.frame_to_pil(frame)
@@ -89,6 +89,7 @@ def live_feed_generator(video_type, confidence_threshold=0.9):
89
  # Draw detections on frame
90
  annotated_frame = video_service.draw_detections(frame, detections)
91
  annotated_frame_rgb = cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)
 
92
  cv2.imshow("Debug Frame", annotated_frame_rgb)
93
  cv2.waitKey(1)
94
  print(f"Annotated frame shape: {annotated_frame_rgb.shape}")
 
62
 
63
  while cap.isOpened():
64
  ret, frame = cap.read()
65
+ if not ret or frame is None or frame.size == 0:
66
+ print(f"Frame read failed or empty at frame count {state.frame_count}")
67
  cap.set(cv2.CAP_PROP_POS_FRAMES, 0) # Loop the video
68
  continue
69
  else:
70
+ print(f"Frame shape: {frame.shape} at frame count {state.frame_count}")
71
 
72
  state.frame_count += 1
73
  frame_pil = video_service.frame_to_pil(frame)
 
89
  # Draw detections on frame
90
  annotated_frame = video_service.draw_detections(frame, detections)
91
  annotated_frame_rgb = cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)
92
+ print(f"Annotated frame shape (RGB): {annotated_frame_rgb.shape}, dtype: {annotated_frame_rgb.dtype}")
93
  cv2.imshow("Debug Frame", annotated_frame_rgb)
94
  cv2.waitKey(1)
95
  print(f"Annotated frame shape: {annotated_frame_rgb.shape}")