surveillance / app.py
SuriRaja's picture
Update app.py
d715067
raw
history blame
1.37 kB
import gradio as gr
import cv2
from services.video_service import get_video_frame
from services.detection_service import detect_objects
from services.thermal_service import detect_thermal_anomalies
from services.shadow_detection import detect_shadow_coverage
from services.salesforce_dispatcher import send_to_salesforce
from services.thermal_service import overlay_thermal_boxes
frame_gen = get_video_frame("data/drone_day.mp4")
def monitor_feed():
try:
frame = next(frame_gen)
temp_path = "temp.jpg"
cv2.imwrite(temp_path, frame)
detections = detect_objects(temp_path)
thermal_boxes = detect_thermal_anomalies(temp_path)
shadow_flag = detect_shadow_coverage(temp_path)
alert_payload = {
"detections": detections,
"thermal": bool(thermal_boxes),
"shadow_issue": shadow_flag,
}
# 🚨🚨🚨 ATTENTION! 🚨🚨🚨
# πŸ”₯ THE BELOW LINE SHOULD BE RE-ENABLED AFTER CONFIGURING SALESFORCE URL PROPERLY πŸ”₯
# send_to_salesforce(alert_payload)
frame = overlay_thermal_boxes(temp_path, thermal_boxes)
return frame
except StopIteration:
return None
iface = gr.Interface(
fn=monitor_feed,
inputs=[],
outputs="image",
live=True,
title="Solar Surveillance Feed Simulation"
)
iface.launch()