Sanshruth commited on
Commit
f7a2ee2
·
verified ·
1 Parent(s): 11db7b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -26,9 +26,9 @@ logger.info(f"OpenCV using {cv2.getNumThreads()} threads out of {cpu_cores} avai
26
 
27
  def extract_first_frame(stream_url):
28
  """
29
- Extracts the current frame from the IP camera stream and returns it as a PIL image.
30
  """
31
- logger.info("Attempting to extract the current frame from the stream...")
32
  cap = cv2.VideoCapture(stream_url)
33
  if not cap.isOpened():
34
  logger.error("Error: Could not open stream.")
@@ -38,15 +38,15 @@ def extract_first_frame(stream_url):
38
  cap.release()
39
 
40
  if not ret:
41
- logger.error("Error: Could not read the current frame.")
42
- return None, "Error: Could not read the current frame."
43
 
44
  # Convert the frame to a PIL image
45
  frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
46
  pil_image = Image.fromarray(frame_rgb)
47
 
48
- logger.info("Current frame extracted successfully.")
49
- return pil_image, "Current frame extracted successfully."
50
 
51
  def update_line(image, evt: gr.SelectData):
52
  """
 
26
 
27
  def extract_first_frame(stream_url):
28
  """
29
+ Extracts the first available frame from the IP camera stream and returns it as a PIL image.
30
  """
31
+ logger.info("Attempting to extract the first frame from the stream...")
32
  cap = cv2.VideoCapture(stream_url)
33
  if not cap.isOpened():
34
  logger.error("Error: Could not open stream.")
 
38
  cap.release()
39
 
40
  if not ret:
41
+ logger.error("Error: Could not read the first frame.")
42
+ return None, "Error: Could not read the first frame."
43
 
44
  # Convert the frame to a PIL image
45
  frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
46
  pil_image = Image.fromarray(frame_rgb)
47
 
48
+ logger.info("First frame extracted successfully.")
49
+ return pil_image, "First frame extracted successfully."
50
 
51
  def update_line(image, evt: gr.SelectData):
52
  """