Spaces:
Build error
Build error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +19 -10
src/streamlit_app.py
CHANGED
@@ -1,17 +1,26 @@
|
|
1 |
-
import streamlit as st
|
2 |
import cv2
|
3 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
|
10 |
-
#
|
11 |
-
cv2.
|
12 |
|
13 |
-
|
14 |
-
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
15 |
|
16 |
-
|
17 |
-
st.image(image_rgb, caption="Red Circle", use_column_width=True)
|
|
|
|
|
1 |
import cv2
|
2 |
import numpy as np
|
3 |
+
import streamlit as st
|
4 |
+
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
|
5 |
+
|
6 |
+
st.title("Live Fault Detection in Utility Poles")
|
7 |
+
|
8 |
+
class FaultDetector(VideoTransformerBase):
|
9 |
+
def transform(self, frame):
|
10 |
+
img = frame.to_ndarray(format="bgr24")
|
11 |
+
|
12 |
+
# Convert to grayscale
|
13 |
+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
14 |
|
15 |
+
# Apply Gaussian blur
|
16 |
+
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
|
17 |
|
18 |
+
# Perform Canny edge detection
|
19 |
+
edges = cv2.Canny(blurred, 50, 150)
|
20 |
|
21 |
+
# Convert edges to 3-channel image
|
22 |
+
edges_colored = cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR)
|
23 |
|
24 |
+
return edges_colored
|
|
|
25 |
|
26 |
+
webrtc_streamer(key="fault_detection", video_transformer_factory=FaultDetector)
|
|