# ============================================================================= # Edge RK3588 production sack counter + dashboard # Shared config for: counter_live_rknn.py + counter_dashboard.py # System Mode: MANUAL START & END BATCH # Copy to .env on device: cp config.env.example .env && nano .env # ============================================================================= # --- Core paths --- # Root output directory (logs, DB, video, CSV) OUTPUT_DIR=/opt/feedmill # SQLite database path for batch entries & crossing logs DB_PATH=/opt/feedmill/feedmill.db # JSON file persisting the current active batch state STATE_FILE=/opt/feedmill/bytetrack_current_batch.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, e.g. yolo11n.rknn) MODEL_PATH=/opt/models/yolo9t.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=7 # Compute device index (reserved; not used at runtime) DEVICE=0 # --- YOLO decoder --- # Number of object classes the model outputs (1 = sack only) NUM_CLASSES=1 # Apply sigmoid to raw class scores (true/false); set true if model head uses BCE logits SCORE_SIGMOID=false # --- Detection --- # Default confidence threshold – dipakai jika confidence per objek di bawah dikosongkan CONF=0.3 # Confidence threshold khusus per objek (0.0 - 1.0). Kosongkan jika ingin mengikuti CONF di atas. SACK_CONF=0.3 BOX_CONF=0.3 TRUCK_CONF=0.3 # NMS IoU threshold (0.0 - 1.0): boxes with IoU above this are merged during non-max suppression IOU=0.45 # --- ByteTrack tracking --- # Counted sack class, index 0 # Detections with score ≥ this get priority matching in the first association stage TRACK_HIGH_THRESH_0=0.25 # Detections with score between this and TRACK_HIGH_THRESH are matched in the second stage TRACK_LOW_THRESH_0=0.1 # IoU threshold for the first-stage association (0–1). Higher = stricter overlap required TRACK_MATCH_THRESH_0=0.3 # Frames a track survives without a match before being permanently removed TRACK_BUFFER_0=30 # Minimum consecutive (or total) hits needed before a track is considered confirmed TRACK_MIN_HITS_0=3 # --- ID-switch dedup guard --- # Prevents double counting when a track's ID changes right at the counting line: # after a crossing, a second crossing from a replacement (previously-inactive) track # within DEDUP_FRAMES frames and DEDUP_PX pixels along the line is ignored. # Simultaneous active tracks are never blocked. Set DEDUP_PX=-1 to disable. DEDUP_FRAMES=4 DEDUP_PX=35 # --- Display --- # Site name shown on the dashboard header (top-right) SITE_NAME=ZenAi # --- Object class names --- # Camera / location identifier shown in HUD and stored in DB CAMERA_NAME=ZenAi # Label used for batch grouping in the database OBJECT_LABEL=sack,box,truck # Class name for the counted object (must match NUM_CLASSES order, index 0) CLASS_COUNTED_OBJECT=sack,box,truck # Class IDs that are tracked and counted (0=sack, 1=box) COUNTED_CLASS_IDS=0,1 # Class ID for truck detection used to determine the horizontal counting zone (2=truck) TRUCK_CLASS_ID=2 # --- Horizontal Counting Zone (Full Vertical Height) --- # Mode zona hitung horizontal: # auto = mengikuti posisi X dari deteksi truck (dengan fallback & hold jika deteksi hilang) # manual = selalu menggunakan batas X tetap dari ZONE_X_MIN/MAX atau ZONE_X_MIN_FRAC/MAX_FRAC ZONE_MODE=auto # Batas kiri & kanan zona dalam pixel (kosongkan jika ingin memakai FRAC di bawah) ZONE_X_MIN= ZONE_X_MAX= # Batas kiri & kanan zona dalam rasio lebar frame (0.0 - 1.0). Digunakan saat ZONE_X_MIN/MAX kosong. ZONE_X_MIN_FRAC=0.30 ZONE_X_MAX_FRAC=0.80 # Tambahan lebar (padding kiri & kanan dalam pixel) pada bounding box truck saat ZONE_MODE=auto TRUCK_ZONE_PAD_X=10 # Berapa detik zona truck terakhir dipertahankan saat deteksi truck sempat hilang (ZONE_MODE=auto) TRUCK_ZONE_HOLD_SEC=300 # --- Line crossing --- # Counting axis: auto | x | y. Use y for sacks moving down across a horizontal line. COUNT_AXIS=y # Direction for counting: down (top-to-bottom) | up | ltr | rtl | both CROSS_DIRECTION=down # Fixed x-coordinate for the counting line (used when COUNT_AXIS=x) LINE_X= # Fraction of frame width where the counting line is drawn (default 0.5 = centre) LINE_X_FRAC=0.5 # Fixed y-coordinate for the counting line (used when COUNT_AXIS=y) LINE_Y= # Fraction of frame height where the counting line is drawn (default 0.5 = centre) LINE_Y_FRAC=0.5 # --- Batch management (MANUAL TRIGGER) --- # Operating mode: manual | auto # manual: Operator clicks "START BATCH" to start counting and "STOP BATCH" to finish BATCH_MODE=manual # Internal IPC control server (counter_live_rknn <-> counter_dashboard) COUNTER_CONTROL_HOST=127.0.0.1 COUNTER_CONTROL_PORT=5001 # Daily cutoff time (HH:MM) – batch numbering resets after this time each day DAILY_CUTOFF_TIME=06:00 CUTOFF_TIME=06:00 # Reset frame counter and ByteTrack track-ID counter back to 0 at daily cutoff RESET_COUNTERS_AT_CUTOFF=true # Timeout in seconds without line crossings before auto mode closes a batch. # While a truck is detected in the counting zone ROI, the timer is held; once no # truck is in the zone, the 30s countdown runs. (Disabled in manual mode.) BATCH_TIMEOUT_SECONDS=30 # Minimum sacks per batch to persist to database (set to 1 for manual mode) MIN_OBJECT_PER_BATCH=1 # Minimum duration in seconds a batch must be open (set to 0 for manual mode) MIN_DURATION_PER_BATCH=0 # --- CSV export --- # Write per-crossing events to a CSV file (true/false) EXPORT_CSV=true # Path where the crossing CSV is written CROSS_CSV=/opt/feedmill/batch_crossings.csv # --- Rate / performance --- # Motion detection pre-filter (true/false) MOTION_DETECTION_ENABLED=false MOTION_THRESHOLD=5.0 RATE_WINDOW_SEC=60 WARMUP_FRAMES=30 RECONNECT_DELAY_SEC=3 MAX_RECONNECT_ATTEMPTS=0 # Cap stream error messages per outage (0 = unlimited + keep FFmpeg stderr) STREAM_ERROR_LOG_MAX=3 FLUSH_EVERY_N_FRAMES=100 TRACKED_PRUNE_SEC=300 # --- Video recording --- RECORD_VIDEO=false VIDEO_SEGMENT_SEC=3600 OUTPUT_FPS=15 # --- Live stream snapshot --- LIVE_STREAM_ENABLED=false LIVE_STREAM_FRAME_PATH=/dev/shm/feedmill/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 # Web access port for users/operators DASHBOARD_PORT=7000 FLASK_DEBUG=false CURRENT_BATCH_PATH=/opt/feedmill/bytetrack_current_batch.json # Shared secret for FCP -> ZenAI peer sync (X-API-Key header) PEER_API_TOKEN=