Skip to content

Haeako/deepstream-python-pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AICamera

AICamera is a DeepStream-based camera analytics project for running YOLO detection on RTSP/video streams, tracking objects, checking configured restricted zones, and sending alerts through Kafka, Telegram, a dashboard API, and a small web monitor for camera/ROI management.

Features

  • RTSP or video-file input through NVIDIA DeepStream/GStreamer.
  • YOLO11 inference using ONNX/TensorRT configuration.
  • Multi-camera configuration with polygon-based restricted zones.
  • Kafka event pipeline for detection messages.
  • Telegram alert sender for snapshots and text alerts.
  • Dashboard push worker for external alert APIs.
  • Flask web monitor for snapshots and polygon/camera configuration.

Repository Layout

apps/                  DeepStream pipeline, alert workers, camera config
apps/config/           YOLO, tracker, label, and camera polygon config files
bindings/              DeepStream Python binding sources
model/                 ONNX model files
web_monitor/           Flask web monitor and templates
kafka_2.13-4.1.1/      Local Kafka distribution used by run.sh
run.sh                 Helper script to start Kafka and the DeepStream app
.env.example           Example runtime configuration without real secrets

Requirements

  • Jetson Orin Nano is recommended for DeepStream.
  • NVIDIA GPU or Jetson device with compatible drivers.
  • NVIDIA DeepStream SDK 7.1.
  • Python 3.10.
  • GStreamer Python bindings.
  • Kafka 4.1.1, included locally or downloaded by run.sh.

Install common Python packages:

pip3 install -r web_monitor/requirements.txt
pip3 install confluent-kafka opencv-python numpy requests python-dotenv

On Ubuntu/Jetson, install DeepStream/GStreamer dependencies if missing:

sudo apt update
sudo apt install python3-gi python3-dev python3-gst-1.0 -y
sudo apt install libgstrtspserver-1.0-0 gstreamer1.0-rtsp -y

Configuration

Create a local .env file from the example:

cp .env.example .env

Fill in real values only in .env. Do not commit .env.

RTSP_URL=rtsp://user:password@192.168.1.10/
VIDEO_SOURCES=rtsp://user:password@192.168.1.10/
TELEGRAM_BOT_TOKEN=123456:replace_me
TELEGRAM_CHAT_ID=-1001234567890
KAFKA_TOPIC=deepstream-test
KAFKA_SERVER=localhost:9092
KAFKA_GROUP=tele_notifier_group
DASHBOARD_API_URL=https://api.example.com/push_alert
DEBUG_DS=0
PORT=8000

apps/config/config.json stores camera metadata and polygons. Keep camera credentials out of committed config files; use placeholder RTSP values in Git and put real stream URLs in .env or a local ignored config.

Run The Main Pipeline

From the repository root:

chmod +x run.sh
./run.sh

The script:

  1. Loads .env when present.
  2. Starts or initializes local Kafka.
  3. Creates the configured Kafka topic if needed.
  4. Runs apps/hls_yolo_11.py with the configured RTSP URL.

You can also run the DeepStream pipeline directly:

cd apps
DEBUG_DS=0 python3 hls_yolo_11.py -i "$RTSP_URL"

Run Alert Workers

Telegram Kafka notifier:

cd apps
python3 kafka_send_message.py

Dashboard notifier:

cd apps
python3 dash_board.py

Both workers read Kafka settings from .env. Telegram also requires TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID.

Run Web Monitor

cd web_monitor
python3 server.py

Open:

http://localhost:8000

Set VIDEO_SOURCES in .env as a comma-separated list for multiple cameras:

VIDEO_SOURCES=rtsp://user:pass@cam-1/,rtsp://user:pass@cam-2/

Model And DeepStream Notes

  • The DeepStream primary inference config is apps/config/config_infer_primary_yolo11.txt.
  • The labels file is apps/config/labels.txt.
  • Tracker settings live in apps/config/dstest2_tracker_config.txt and apps/config/config_tracker_NvDCF_perf.yml.
  • The ONNX files are stored in model/.
  • TensorRT engine files are generated locally and should not be committed.

If GStreamer behaves unexpectedly, clear the local cache:

rm -rf "$HOME/.cache/gstreamer-1.0/"*

Security

This repo intentionally avoids committing real camera URLs, Telegram tokens, chat IDs, API keys, and local .env files. Use .env.example as documentation and keep real values in .env or your deployment secret manager.

If a real secret was committed before, rotate it in the provider dashboard because deleting it from the current files does not remove it from Git history.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors