Spaces:
Running
Running
Update app.py
Browse files
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
|
30 |
"""
|
31 |
-
logger.info("Attempting to extract the
|
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
|
42 |
-
return None, "Error: Could not read the
|
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("
|
49 |
-
return pil_image, "
|
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 |
"""
|