AI-Powered Surveillance Camera System for macOS — RTSP & Dahua DVR support with YOLOv8 detection, zone alerts, Telegram notifications
Python
60
2 commits
updated Apr 6, 2026
AI-Powered Surveillance Camera System for macOS
Camai is a macOS menu bar application that connects to any RTSP IP camera or Dahua DVR system, providing live camera feeds with AI-powered object detection, zone-based alerts, and image super-resolution enhancement.
git clone https://github.com/hrrcne/camai.git
cd camai
pip3 install -r requirements.txt
Copy the example config and edit with your camera details:
cp config.example.json config.json
cp sentinel_config.example.json sentinel_config.json
Edit config.json for RTSP cameras:
{
"title": "MY HOME",
"cameras": [
{
"name": "Front Door",
"type": "rtsp",
"url": "rtsp://admin:[email protected]:554/stream1"
},
{
"name": "Backyard",
"type": "rtsp",
"url": "rtsp://admin:[email protected]:554/h264Preview_01_main"
}
],
"always_on_channel": 1
}
Or for Dahua DVR (legacy format):
{
"dvr_ip": "192.168.1.100",
"dvr_user": "admin",
"dvr_pass": "your_password",
"channels": 4,
"channel_names": ["Front Door", "Backyard", "Garage", "Driveway"],
"title": "MY HOME",
"always_on_channel": 1
}
Or skip this step and use the built-in Setup Wizard when you first launch the app.
./start.sh
This will:
| Brand | URL Format |
|---|---|
| Hikvision | rtsp://admin:pass@IP:554/Streaming/Channels/101 |
| Reolink | rtsp://admin:pass@IP:554/h264Preview_01_main |
| Dahua | rtsp://admin:pass@IP:554/cam/realmonitor?channel=1&subtype=0 |
| Amcrest | rtsp://admin:pass@IP:554/cam/realmonitor?channel=1&subtype=0 |
| TP-Link Tapo | rtsp://admin:pass@IP:554/stream1 |
| Uniview | rtsp://admin:pass@IP:554/unicast/c1/s0/live |
| Generic | rtsp://IP:554/stream or rtsp://IP:554/h264 |
Note: Most cameras use port 554 for RTSP. Username/password are embedded in the URL.
config.json)| Field | Description |
|---|---|
title | Title shown in the app header |
cameras | Array of camera objects |
cameras[].name | Display name for the camera |
cameras[].type | "rtsp" for IP cameras |
cameras[].url | Full RTSP URL including credentials |
always_on_channel | Channel that runs 24/7 for AI detection |
| Field | Description |
|---|---|
dvr_ip | DVR IP address on your network |
dvr_user | DVR username (usually admin) |
dvr_pass | DVR password |
channels | Number of camera channels (1-16) |
channel_names | Array of display names for each camera |
title | Title shown in the app header |
always_on_channel | Channel that runs 24/7 for AI detection |
sentinel_config.json)Controls the AI detection engine:
See sentinel_config.example.json for all options.
Camai supports AI super-resolution for zoomed camera regions:
.env:
FAL_API_KEY=your_api_key_here
Without fal.ai, Camai falls back to local classical upscaling.
https://api.telegram.org/bot<TOKEN>/getUpdates)sentinel_config.json under alerts.telegram, or add to .env:
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
To package as a standalone macOS app:
cd electron-app
npm install
npm run build
The built app will be in electron-app/dist/.
camai/
├── server.py # Flask MJPEG server (RTSP + Dahua) + AI enhance endpoints
├── sentinel/ # AI detection engine
│ ├── engine.py # Main orchestrator
│ ├── detector.py # YOLOv8 inference (CoreML/MPS)
│ ├── tracker.py # IoU-based multi-object tracker
│ ├── zones.py # Polygon zone management
│ ├── behavior.py # Lingering/approach analysis
│ ├── alerter.py # Alert dispatch (macOS/Telegram/WS)
│ ├── recorder.py # Snapshot + video clip recording
│ ├── db.py # SQLite event database
│ ├── motion.py # MOG2 motion detection
│ ├── daynight.py # Day/night detection
│ ├── ws_server.py # WebSocket alert server
│ ├── api.py # REST API blueprint
│ └── config.py # Config loader with hot-reload
├── electron-app/ # Electron menu bar UI
│ ├── main.js # Main process (tray, window)
│ ├── renderer.js # Camera grid, zoom, enhance, events, zones
│ ├── index.html # App layout
│ └── style.css # Dark theme styles
└── scripts/
└── export_coreml.py # One-time CoreML model export
RTSP Camera / Dahua DVR --> server.py (decode, MJPEG serve)
|
v
Sentinel Engine
(motion -> YOLO -> track -> zone -> behavior -> alert)
|
+-- macOS notifications
+-- Telegram messages
+-- WebSocket -> Electron UI
+-- SQLite database
+-- Snapshot/clip recording
| Key | Action |
|---|---|
| Click camera | Expand to full view |
| Right-click drag | Select region for zoom/enhance |
E | Toggle event timeline |
Z | Toggle zone editor |
ESC | Close panels, reset zoom, collapse grid |
MIT License - see LICENSE for details.
AI-Powered Surveillance Camera System for macOS — RTSP & Dahua DVR support with YOLOv8 detection, zone alerts, Telegram notifications
Python
60
2 commits
updated Apr 6, 2026
AI-Powered Surveillance Camera System for macOS
Camai is a macOS menu bar application that connects to any RTSP IP camera or Dahua DVR system, providing live camera feeds with AI-powered object detection, zone-based alerts, and image super-resolution enhancement.
git clone https://github.com/hrrcne/camai.git
cd camai
pip3 install -r requirements.txt
Copy the example config and edit with your camera details:
cp config.example.json config.json
cp sentinel_config.example.json sentinel_config.json
Edit config.json for RTSP cameras:
{
"title": "MY HOME",
"cameras": [
{
"name": "Front Door",
"type": "rtsp",
"url": "rtsp://admin:[email protected]:554/stream1"
},
{
"name": "Backyard",
"type": "rtsp",
"url": "rtsp://admin:[email protected]:554/h264Preview_01_main"
}
],
"always_on_channel": 1
}
Or for Dahua DVR (legacy format):
{
"dvr_ip": "192.168.1.100",
"dvr_user": "admin",
"dvr_pass": "your_password",
"channels": 4,
"channel_names": ["Front Door", "Backyard", "Garage", "Driveway"],
"title": "MY HOME",
"always_on_channel": 1
}
Or skip this step and use the built-in Setup Wizard when you first launch the app.
./start.sh
This will:
| Brand | URL Format |
|---|---|
| Hikvision | rtsp://admin:pass@IP:554/Streaming/Channels/101 |
| Reolink | rtsp://admin:pass@IP:554/h264Preview_01_main |
| Dahua | rtsp://admin:pass@IP:554/cam/realmonitor?channel=1&subtype=0 |
| Amcrest | rtsp://admin:pass@IP:554/cam/realmonitor?channel=1&subtype=0 |
| TP-Link Tapo | rtsp://admin:pass@IP:554/stream1 |
| Uniview | rtsp://admin:pass@IP:554/unicast/c1/s0/live |
| Generic | rtsp://IP:554/stream or rtsp://IP:554/h264 |
Note: Most cameras use port 554 for RTSP. Username/password are embedded in the URL.
config.json)| Field | Description |
|---|---|
title | Title shown in the app header |
cameras | Array of camera objects |
cameras[].name | Display name for the camera |
cameras[].type | "rtsp" for IP cameras |
cameras[].url | Full RTSP URL including credentials |
always_on_channel | Channel that runs 24/7 for AI detection |
| Field | Description |
|---|---|
dvr_ip | DVR IP address on your network |
dvr_user | DVR username (usually admin) |
dvr_pass | DVR password |
channels | Number of camera channels (1-16) |
channel_names | Array of display names for each camera |
title | Title shown in the app header |
always_on_channel | Channel that runs 24/7 for AI detection |
sentinel_config.json)Controls the AI detection engine:
See sentinel_config.example.json for all options.
Camai supports AI super-resolution for zoomed camera regions:
.env:
FAL_API_KEY=your_api_key_here
Without fal.ai, Camai falls back to local classical upscaling.
https://api.telegram.org/bot<TOKEN>/getUpdates)sentinel_config.json under alerts.telegram, or add to .env:
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
To package as a standalone macOS app:
cd electron-app
npm install
npm run build
The built app will be in electron-app/dist/.
camai/
├── server.py # Flask MJPEG server (RTSP + Dahua) + AI enhance endpoints
├── sentinel/ # AI detection engine
│ ├── engine.py # Main orchestrator
│ ├── detector.py # YOLOv8 inference (CoreML/MPS)
│ ├── tracker.py # IoU-based multi-object tracker
│ ├── zones.py # Polygon zone management
│ ├── behavior.py # Lingering/approach analysis
│ ├── alerter.py # Alert dispatch (macOS/Telegram/WS)
│ ├── recorder.py # Snapshot + video clip recording
│ ├── db.py # SQLite event database
│ ├── motion.py # MOG2 motion detection
│ ├── daynight.py # Day/night detection
│ ├── ws_server.py # WebSocket alert server
│ ├── api.py # REST API blueprint
│ └── config.py # Config loader with hot-reload
├── electron-app/ # Electron menu bar UI
│ ├── main.js # Main process (tray, window)
│ ├── renderer.js # Camera grid, zoom, enhance, events, zones
│ ├── index.html # App layout
│ └── style.css # Dark theme styles
└── scripts/
└── export_coreml.py # One-time CoreML model export
RTSP Camera / Dahua DVR --> server.py (decode, MJPEG serve)
|
v
Sentinel Engine
(motion -> YOLO -> track -> zone -> behavior -> alert)
|
+-- macOS notifications
+-- Telegram messages
+-- WebSocket -> Electron UI
+-- SQLite database
+-- Snapshot/clip recording
| Key | Action |
|---|---|
| Click camera | Expand to full view |
| Right-click drag | Select region for zoom/enhance |
E | Toggle event timeline |
Z | Toggle zone editor |
ESC | Close panels, reset zoom, collapse grid |
MIT License - see LICENSE for details.