Sanjayraju30 commited on
Commit
6fdfebc
·
verified ·
1 Parent(s): 719a47f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- st.title("OpenCV Image Display Example")
 
6
 
7
- # Create a black image
8
- image = np.zeros((200, 200, 3), dtype=np.uint8)
9
 
10
- # Draw a red circle
11
- cv2.circle(image, (100, 100), 50, (0, 0, 255), -1)
12
 
13
- # Convert BGR to RGB
14
- image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
15
 
16
- # Display the image in Streamlit
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)