Spaces:
Build error
Build error
File size: 765 Bytes
562f13d e198f1a 6fdfebc 9f77b8d 6fdfebc 9f77b8d 6fdfebc 9f77b8d 6fdfebc 9f77b8d 6fdfebc 9f77b8d 6fdfebc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import cv2
import numpy as np
import streamlit as st
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
st.title("Live Fault Detection in Utility Poles")
class FaultDetector(VideoTransformerBase):
def transform(self, frame):
img = frame.to_ndarray(format="bgr24")
# Convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Apply Gaussian blur
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
# Perform Canny edge detection
edges = cv2.Canny(blurred, 50, 150)
# Convert edges to 3-channel image
edges_colored = cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR)
return edges_colored
webrtc_streamer(key="fault_detection", video_transformer_factory=FaultDetector)
|