forked from dsutanto/zenai-kpc-python
142 lines
4.5 KiB
Plaintext
142 lines
4.5 KiB
Plaintext
# =============================================================================
|
||
# ZenAI KPC edge counter + dashboard
|
||
# Shared config for: counter_live_rknn.py + counter_dashboard.py
|
||
#
|
||
# On device:
|
||
# cp env.example .env && nano .env
|
||
#
|
||
# Install path (systemd): /opt/zenai-kpc-python
|
||
# Data path: /opt/zenai-kpc-counter
|
||
# See DEPLOY.md for full setup instructions.
|
||
# =============================================================================
|
||
|
||
# --- Core paths ---
|
||
# Root output directory (video segments, default snapshot/CSV paths)
|
||
OUTPUT_DIR=/opt/zenai-kpc-counter
|
||
# SQLite database path for daily counter records
|
||
DB_PATH=/opt/zenai-kpc-counter/counter.db
|
||
# JSON file for the active counting-day state (counter writes, dashboard reads)
|
||
STATE_FILE=/opt/zenai-kpc-counter/current_counter.json
|
||
|
||
# --- Input source ---
|
||
# RTSP / HTTP live stream, or a local video file path
|
||
SOURCE=rtsp://user:pass@192.168.0.100:554/stream1
|
||
# FFmpeg capture options passed to cv2.VideoCapture (RTSP low-latency flags)
|
||
OPENCV_FFMPEG_CAPTURE_OPTIONS=rtsp_transport;tcp|fflags;nobuffer|flags;low_delay
|
||
|
||
# --- RKNN model ---
|
||
# Path to exported .rknn model (YOLO format)
|
||
MODEL_PATH=/opt/models/your_model.rknn
|
||
# Input image size for the model (square, e.g. 320 → 320×320)
|
||
IMGSZ=320
|
||
# Use FP16 inference on NPU (true/false); currently unused in ByteTrack variant
|
||
HALF=false
|
||
# NPU core mask: 1=core0, 2=core1, 3=core0+core1, 7=all three
|
||
CORE_MASK=1
|
||
# Compute device index (reserved; not used at runtime)
|
||
DEVICE=0
|
||
|
||
# --- YOLO decoder ---
|
||
# Number of object classes the model outputs
|
||
NUM_CLASSES=4
|
||
# Apply sigmoid to raw class scores (true/false); set true if model head uses BCE logits
|
||
SCORE_SIGMOID=false
|
||
|
||
# --- Detection ---
|
||
# Confidence threshold – detections below this are discarded before NMS
|
||
CONF=0.5
|
||
|
||
# --- ByteTrack tracking ---
|
||
# Detections with score >= this get priority matching in the first association stage
|
||
TRACK_HIGH_THRESH=0.5
|
||
# Detections with score between this and TRACK_HIGH_THRESH are matched in the second stage
|
||
TRACK_LOW_THRESH=0.3
|
||
# IoU threshold for the first-stage association (0–1). Higher = stricter overlap required
|
||
TRACK_MATCH_THRESH=0.7
|
||
# Frames a track survives without a match before being permanently removed
|
||
TRACK_BUFFER=60
|
||
# Minimum consecutive (or total) hits needed before a track is considered confirmed
|
||
TRACK_MIN_HITS=3
|
||
|
||
# --- ID-switch counting guards ---
|
||
# Dedup guard: ignore a second crossing in the same direction within DEDUP_FRAMES
|
||
# frames and DEDUP_PX horizontal pixels (set DEDUP_PX=-1 to disable).
|
||
DEDUP_FRAMES=15
|
||
DEDUP_PX=60
|
||
# Inheritance guard: new tracks inherit position from a recently-seen nearby track
|
||
# (set INHERIT_PX=-1 to disable).
|
||
INHERIT_SEC=1.0
|
||
INHERIT_PX=60
|
||
|
||
# --- Display ---
|
||
# Site name shown on the dashboard header
|
||
SITE_NAME=ZenAi
|
||
|
||
# --- Object class names ---
|
||
# Camera / location identifier shown in HUD and stored in DB
|
||
CAMERA_NAME=ZenAi
|
||
# Label used for grouping in the database
|
||
OBJECT_LABEL=karung
|
||
# Class name for the counted object (must match model class order)
|
||
CLASS_OBJECT=karung
|
||
# Model class ID for the object being counted (default 0)
|
||
OBJECT_CLASS_ID=0
|
||
|
||
# --- Line crossing ---
|
||
# Line 1 (~upper): counts top-to-down (IN). Line 2 (~lower): bottom-to-up (OUT).
|
||
# Fixed y-coordinate overrides the fraction if set.
|
||
LINE_Y1=
|
||
LINE_Y1_FRAC=0.70
|
||
LINE_Y2=
|
||
LINE_Y2_FRAC=0.30
|
||
|
||
# --- Counting day management ---
|
||
# New counting day starts after this time (HH:MM).
|
||
DAILY_CUTOFF_TIME=20:00
|
||
CUTOFF_TIME=20:00
|
||
|
||
# --- CSV export ---
|
||
EXPORT_CSV=false
|
||
CROSS_CSV=/opt/zenai-kpc-counter/crossings.csv
|
||
|
||
# --- Crossing snapshots ---
|
||
SAVE_CROSS_SNAPSHOT=true
|
||
SAVE_DETECT_SNAPSHOT=false
|
||
CROSS_SNAPSHOT_DIR=/opt/zenai-kpc-counter/snapshots
|
||
CROSS_SNAPSHOT_QUALITY=85
|
||
CROSS_SNAPSHOT_MAX_FILES=1000
|
||
CROSS_SNAPSHOT_MAX_AGE_DAYS=3
|
||
CROSS_SNAPSHOT_CLEANUP_SEC=3600
|
||
|
||
# --- Rate / performance ---
|
||
MOTION_DETECTION_ENABLED=true
|
||
MOTION_PIXEL_DELTA=25
|
||
MOTION_MIN_AREA_FRAC=0.002
|
||
MOTION_HEARTBEAT_FRAMES=15
|
||
MOTION_THRESHOLD=5.0
|
||
RATE_WINDOW_SEC=60
|
||
WARMUP_FRAMES=30
|
||
RECONNECT_DELAY_SEC=3
|
||
MAX_RECONNECT_ATTEMPTS=0
|
||
TRACKED_PRUNE_SEC=300
|
||
|
||
# --- Video recording ---
|
||
RECORD_VIDEO=false
|
||
VIDEO_SEGMENT_SEC=3600
|
||
OUTPUT_FPS=15
|
||
|
||
# --- Live stream snapshot ---
|
||
LIVE_STREAM_ENABLED=true
|
||
LIVE_STREAM_FRAME_PATH=/dev/shm/zenai-kpc-counter/live_frame.jpg
|
||
LIVE_STREAM_QUALITY=75
|
||
LIVE_STREAM_EVERY_N=2
|
||
|
||
# --- Dashboard (counter_dashboard.py) ---
|
||
SECRET_KEY=change-me-in-production
|
||
DASHBOARD_HOST=0.0.0.0
|
||
DASHBOARD_PORT=5000
|
||
FLASK_DEBUG=false
|
||
|
||
# Debug: set DEBUG_TRACKING=true to log per-frame tracking details to stdout
|
||
# DEBUG_TRACKING=false
|