AI-Powered Neighborhood Safety System for Wildlife and Wildfire Detection
Ursa transforms neighborhood security cameras into an intelligent safety network that detects wildfires and wildlife threats, automatically alerts emergency services, and keeps your community informed in real-time.
Built with cutting-edge AI agents that analyze video feeds, assess threats, and autonomously coordinate emergency responses to protect your neighborhood from wildfires and dangerous wildlife encounters.
- Real-Time Fire Detection: AI agents continuously monitor camera feeds for signs of wildfire, smoke, and fire
- Automatic Emergency Calls: System autonomously calls fire department when wildfire is detected with high confidence
- Multi-Camera Correlation: Tracks fire spread across multiple cameras to provide accurate location data to first responders
- Community-Wide Alerts: Automatically notifies all residents within 50-mile radius via SMS when wildfire is detected
- Dangerous Wildlife Alerts: Detects bears, coyotes, and other potentially dangerous wildlife in residential areas
- Lost Pet Detection: Identifies and tracks lost pets across camera network, coordinating with animal control
- Wildlife Authorities Coordination: Automatically contacts appropriate wildlife authorities for dangerous animal encounters
- Pattern Tracking: Monitors wildlife movement patterns across cameras to predict behavior and protect residents
- Multi-Agent Coordination: AI agents work together across multiple camera feeds to correlate threats
- Intelligent Threat Analysis: Advanced AI analyzes threat severity, confidence levels, and appropriate responses
- Autonomous Emergency Response: AI agents automatically call fire department, wildlife authorities, or animal control based on threat type
- Live Reasoning Visualization: See AI "thinking" in real-time as it analyzes threats and makes decisions
- Contextual Communication: AI generates dynamic, context-aware messages for emergency calls and community notifications
- Interactive Map: Visualize all cameras, active threats, and detections on an interactive neighborhood map
- 50-Mile Radius Notifications: Automatic SMS alerts to all community members within 50 miles of incidents
- Real-Time Updates: WebSocket-powered live updates for instant threat awareness
- Threat Panel: Comprehensive view of all active threats with severity levels and recommended actions
- Backend: Python, FastAPI, WebSockets
- Frontend: React (TypeScript), Vite, Leaflet.js
- AI Detection: YOLOv8 for real-time object detection, OpenCV for video processing
- AI Agents: Multi-agent coordination system with autonomous decision-making
- Emergency Services: Twilio integration for automated calls and SMS notifications
- Communication: Real-time WebSocket updates for instant threat coordination
- Python 3.8+
- Node.js 18+
- npm or yarn
- Twilio account (for emergency calls and SMS notifications)
- Navigate to backend directory:
cd backend- Create virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On Mac/Linux
# or
venv\Scripts\activate # On Windows- Install dependencies:
pip install -r requirements.txt- Configure environment variables:
Create a
.envfile in the backend directory with:
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_PHONE_NUMBER=your_twilio_phone_number
POLICE_NUMBER=+1234567890 # Number to call for emergencies (demo)
BASE_URL=http://localhost:8000
USE_REAL_AI=false # Set to 'true' to enable real AI video analysis- Start the server:
python main.pyOr use the convenience script:
./start_backend.shThe backend will run on http://localhost:8000
- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devOr use the convenience script:
./start_frontend.shThe frontend will run on http://localhost:5173
-
Start both servers (backend and frontend)
-
Open the app in your browser at
http://localhost:5173 -
Start the Wildlife Detection Scenario:
- Click "Start Scenario" in the Control Panel
- Watch as AI agents detect wildfires and wildlife across multiple cameras
- See real-time reasoning in the AI Reasoning panel
- Observe automatic emergency calls being placed
- Watch community notifications being sent
-
Monitor the Dashboard:
- Map View: See camera locations, active threats, and detection zones
- Threat Panel: View all detected threats with severity levels (Critical, High, Medium, Low)
- AI Reasoning Panel: Watch the AI's decision-making process in real-time
- Control Panel: Start/stop scenarios and view system statistics
-
Emergency Response Features:
- When a wildfire is detected, the system automatically calls fire department
- For dangerous wildlife (bears, coyotes), wildlife authorities are contacted
- Lost pets trigger animal control notifications
- All nearby community members (50-mile radius) receive SMS alerts
ursa/
โโโ backend/
โ โโโ agents/
โ โ โโโ coordinator.py # Multi-agent coordination & emergency response
โ โ โโโ camera_agent.py # Individual camera AI agents
โ โ โโโ video_analyzer.py # YOLOv8-based video analysis
โ โ โโโ __init__.py
โ โโโ services/
โ โ โโโ twilio_service.py # Emergency calls & SMS via Twilio
โ โ โโโ community_notifier.py # Community-wide alert system
โ โ โโโ threat_analyzer.py # Threat severity & response analyzer
โ โ โโโ ai_message_generator.py # AI-generated contextual messages
โ โ โโโ __init__.py
โ โโโ demo/
โ โ โโโ scenarios/
โ โ โ โโโ wildlife_detection.py # Wildlife & wildfire scenario
โ โ โ โโโ __init__.py
โ โ โโโ videos/ # Demo video files for AI analysis
โ โโโ main.py # FastAPI server with WebSocket
โ โโโ requirements.txt # Python dependencies
โ โโโ yolov8n.pt # YOLOv8 model weights
โ โโโ verify_setup.py # Setup verification script
โโโ frontend/
โ โโโ src/
โ โ โโโ components/
โ โ โ โโโ MapView.tsx # Interactive Leaflet map
โ โ โ โโโ ThreatPanel.tsx # Active threats display
โ โ โ โโโ ReasoningPanel.tsx # AI reasoning visualization
โ โ โ โโโ ControlPanel.tsx # Scenario controls
โ โ โ โโโ CameraFeed.tsx # Camera video feeds
โ โ โโโ hooks/
โ โ โ โโโ useWebSocket.ts # WebSocket connection hook
โ โ โโโ types.ts # TypeScript type definitions
โ โ โโโ App.tsx # Main application
โ โโโ package.json
โ โโโ vite.config.ts
โ โโโ tsconfig.json
โโโ start_backend.sh # Backend startup script
โโโ start_frontend.sh # Frontend startup script
โโโ test_backend.sh # Backend testing script
โโโ README.md
Simulates real-world wildlife and wildfire threats across the neighborhood:
Wildfire Detection:
- AI detects smoke and fire indicators in camera feeds
- System automatically calls fire department with location details
- All residents within 50 miles receive immediate SMS alerts
- Multi-camera correlation tracks fire spread and direction
Wildlife Encounters:
- Detects bears, coyotes, deer, and other wildlife near residential areas
- Assesses threat level based on animal type and behavior
- Automatically contacts wildlife authorities for dangerous animals
- Sends community alerts to keep residents informed and safe
Lost Pet Recovery:
- Identifies lost pets across multiple camera feeds
- Tracks pet movement patterns throughout neighborhood
- Coordinates with animal control for safe recovery
- Notifies community to assist in reunion efforts
GET /- API status and agent countGET /api/cameras- Get all camera locations and statusGET /api/threats- Get active threats with severity levelsPOST /api/scenarios/start?scenario_name=wildlife_detection- Start wildlife/wildfire demoPOST /api/scenarios/stop- Stop current scenarioPOST /api/twilio/voice- Twilio webhook for emergency call voice contentPOST /api/twilio/call-status- Twilio webhook for call status updatesPOST /api/twilio/sms-status- Twilio webhook for SMS delivery status
ws://localhost:8000/ws- Real-time bidirectional communication- Receives:
detection- New wildlife/wildfire detection eventsthreat- Threat alerts with severity analysisreasoning- AI decision-making logsscenario_started- Scenario initializationscenario_stopped- Scenario completionemergency_call_placed- Emergency service notificationcommunity_notified- Community alert confirmation
- Receives:
The backend uses FastAPI with WebSocket support and a sophisticated multi-agent system:
Core Components:
- AgentCoordinator: Orchestrates multiple camera agents, correlates threats across cameras, manages emergency response
- CameraAgent: Individual AI agents that process video feeds, detect wildlife/wildfire, maintain detection logs
- VideoAnalyzer: YOLOv8-based computer vision for real-time object detection in video streams
- ThreatAnalyzer: Evaluates threat severity (Critical/High/Medium/Low) and determines appropriate responses
- TwilioService: Handles automated emergency calls and SMS notifications to authorities and community
- CommunityNotifier: Manages 50-mile radius community alerts with distance-based targeting
- AIMessageGenerator: Creates contextual, dynamic messages for emergency calls and notifications
Emergency Response Flow:
- Camera agent detects wildlife/wildfire in video feed
- Detection sent to coordinator for multi-camera correlation
- Threat analyzer evaluates severity and confidence level
- If critical: AI agent automatically calls appropriate emergency service
- Community notifier sends SMS alerts to all residents within 50 miles
- Real-time updates broadcast to all connected clients via WebSocket
The frontend is built with React + TypeScript + Vite:
Key Components:
- MapView: Interactive Leaflet.js map showing camera network, threat zones, and detection events
- ThreatPanel: Real-time threat dashboard with severity indicators and recommended actions
- ReasoningPanel: Live AI reasoning visualization showing decision-making process
- ControlPanel: Scenario management, system statistics, and AI mode toggle
- CameraFeed: Video stream visualization for connected cameras
WebSocket Integration:
- Custom
useWebSockethook manages persistent connection - Real-time updates for detections, threats, and AI reasoning
- Automatic reconnection handling
- Type-safe message parsing with TypeScript
Simulated Mode (USE_REAL_AI=false):
- Pre-programmed detection scenarios for demonstration
- No actual video analysis required
- Fast and reliable for testing
Real AI Mode (USE_REAL_AI=true):
- YOLOv8-based computer vision analysis
- Processes actual video files frame-by-frame
- Detects real objects, animals, and fire indicators
- Requires GPU for optimal performance
Backend:
- Framework: FastAPI, Uvicorn
- AI/ML: YOLOv8 (Ultralytics), OpenCV, NumPy
- Communication: WebSockets, Twilio API
- Utilities: Python-dotenv, asyncio
Frontend:
- Framework: React 18, TypeScript, Vite
- Mapping: Leaflet.js, React-Leaflet
- Styling: CSS3, Flexbox/Grid
- State Management: React Hooks
Architecture:
- Multi-Agent System: Autonomous AI agents with coordinated decision-making
- Real-Time Communication: WebSocket bidirectional updates
- Emergency Integration: Twilio for voice calls and SMS
- Computer Vision: YOLOv8 for object and threat detection
Demo Configuration:
- Camera locations are simulated for demonstration purposes
- In demo mode, emergency calls go to configured POLICE_NUMBER (not actual 911)
- Community member database is simulated (would connect to real DB in production)
- Video files in
demo/videos/are used for AI analysis in real mode
Production Considerations:
- Integrate with real IP camera feeds (RTSP/ONVIF protocols)
- Connect to actual emergency dispatch systems with proper authorization
- Implement user authentication and authorization
- Add database for threat history, community members, and camera registry
- Deploy with proper security (HTTPS, API authentication)
- Scale with load balancing and distributed agent processing
- Add false positive reduction with multi-frame verification
Run backend tests:
./test_backend.shTest Twilio integration:
python backend/test_twilio_call.py
python backend/check_twilio_call_status.pyVerify setup:
python backend/verify_setup.pyImportant: This system is designed for demonstration and testing purposes. For production deployment:
- Ensure compliance with local emergency service protocols
- Obtain proper authorization before connecting to 911 or emergency dispatch
- Implement false positive reduction to prevent unnecessary emergency calls
- Follow privacy regulations for video surveillance in your jurisdiction
- Test thoroughly with non-emergency numbers before production use
- Maintain proper logging and audit trails for all emergency calls
Emergency Call Disclaimer: In demo mode, calls are placed to the configured test number, NOT actual emergency services. Configure appropriately for your use case.
- Advanced AI Models: Integration with larger models for improved detection accuracy
- Smoke Detection: Specialized algorithms for early smoke and fire detection
- Wildlife Species Identification: Detailed species classification for appropriate response
- Predictive Analytics: Machine learning to predict wildlife movement patterns
- Mobile App: iOS/Android apps for community members
- Historical Analysis: Long-term trend analysis for wildlife and fire risk
- Integration with Weather Data: Enhanced fire risk assessment with weather conditions
- Drone Integration: Automatic drone deployment for aerial assessment
This project is built to protect neighborhoods from wildfires and wildlife threats. Contributions are welcome! Feel free to open issues or submit pull requests.
MIT License - Built for neighborhood safety and community protection
Built with โค๏ธ to protect neighborhoods from wildfires and wildlife threats
Ursa - Named after Ursa Major (Great Bear constellation), symbolizing our mission to keep communities safe from wildlife and natural threats while maintaining harmony with nature.