DSatishchandra commited on
Commit
62b138f
Β·
verified Β·
1 Parent(s): 62dde81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -41,10 +41,11 @@ def live_feed_generator(video_type, confidence_threshold=0.9):
41
  """Generator for live feed with real-time detection."""
42
  state = LiveFeedState()
43
  video_path = VIDEO_PATHS.get(video_type)
44
-
45
  if not video_path or not os.path.exists(video_path):
46
- yield gr.update(value="Video file not found."), None, None, None, None, None, None
47
- return
 
48
 
49
  cap = cv2.VideoCapture(video_path)
50
  fps = cap.get(cv2.CAP_PROP_FPS)
@@ -53,8 +54,11 @@ def live_feed_generator(video_type, confidence_threshold=0.9):
53
  while cap.isOpened():
54
  ret, frame = cap.read()
55
  if not ret:
 
56
  cap.set(cv2.CAP_PROP_POS_FRAMES, 0) # Loop the video
57
  continue
 
 
58
 
59
  state.frame_count += 1
60
  frame_pil = video_service.frame_to_pil(frame)
 
41
  """Generator for live feed with real-time detection."""
42
  state = LiveFeedState()
43
  video_path = VIDEO_PATHS.get(video_type)
44
+ print(f"Selected video path: {video_path}")
45
  if not video_path or not os.path.exists(video_path):
46
+ print("Video file not found or path is incorrect.")
47
+ yield gr.update(value="Video file not found."), None, None, None, None, None, None
48
+ return
49
 
50
  cap = cv2.VideoCapture(video_path)
51
  fps = cap.get(cv2.CAP_PROP_FPS)
 
54
  while cap.isOpened():
55
  ret, frame = cap.read()
56
  if not ret:
57
+ print(f"Failed to read frame at count {state.frame_count}")
58
  cap.set(cv2.CAP_PROP_POS_FRAMES, 0) # Loop the video
59
  continue
60
+ else:
61
+ print(f"Failed to read frame at count {state.frame_count}")
62
 
63
  state.frame_count += 1
64
  frame_pil = video_service.frame_to_pil(frame)