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

Update services/video_service.py

Browse files
Files changed (1) hide show
  1. services/video_service.py +7 -2
services/video_service.py CHANGED
@@ -17,9 +17,14 @@ class VideoService:
17
  return frames
18
 
19
  def frame_to_pil(self, frame):
20
- """Convert OpenCV frame to PIL Image."""
21
  frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
22
- return Image.fromarray(frame_rgb)
 
 
 
 
 
23
 
24
  def draw_detections(self, frame, detections):
25
  """Draw bounding boxes, labels, and timestamp on frame."""
 
17
  return frames
18
 
19
  def frame_to_pil(self, frame):
20
+ try:
21
  frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
22
+ pil_image = Image.fromarray(frame_rgb)
23
+ return pil_image
24
+ except Exception as e:
25
+ print(f"[Error] frame_to_pil conversion failed: {e}")
26
+ return None
27
+
28
 
29
  def draw_detections(self, frame, detections):
30
  """Draw bounding boxes, labels, and timestamp on frame."""