Files
managed-portal/managed/store_dwell_alert
skye.yue ea618fd674 Refactor store dwell alert management API and dwell engine
- Updated argument parsing in manage_api.py to include new threshold parameters.
- Enhanced _config_payload to include thresholds and webhook configurations.
- Modified _build_summary to track queue metrics and adjust alert reporting.
- Refactored DwellEngine to utilize queue thresholds for alerting and reporting.
- Added queue metrics calculations and status change tracking in dwell_engine.py.
- Updated notifier.py to support posting JSON events to webhooks.
- Adjusted example configuration to reflect new threshold parameters.
- Enhanced Docker entrypoint script for better process management.
- Updated tests to cover new queue metrics and thresholds.
- Improved ManagedServiceDetail and ManagedServices Vue components to display queue metrics.
2026-05-09 11:35:55 +08:00
..
2026-04-27 10:04:36 +08:00
2026-04-27 10:04:36 +08:00
2026-04-27 10:04:36 +08:00
2026-04-27 10:04:36 +08:00
2026-05-07 17:58:26 +08:00
2026-04-27 10:04:36 +08:00
2026-04-27 10:04:36 +08:00

Store Dwell Alert on 192.168.5.108

Local planning project for a single-camera RTSP long-stay alert system running on 192.168.5.108.

Documents:

  • docs/plans/2026-04-15-store-dwell-alert-design.md
  • docs/plans/2026-04-15-store-dwell-alert.md

Scope:

  • Single RTSP store camera
  • YOLO11n person detection
  • Full-frame tracking and lightweight re-association
  • Staff whitelist exclusion
  • Local JSONL event sink
  • Half-hour dwell reports
  • Offline bundle packaging for .108-class Ubuntu hosts
  • Chinese operations guide: README_zh.md

Runtime:

  • Default config path: config/108.local.yaml
  • Event sink path: logs/events.jsonl
  • Continuous mode: python -m app.main
  • Single-frame smoke test: python -m app.main --once
  • Management API mode: python -m app.manage_api --config config/local.yaml --port 18081

Staff gallery:

  • Directory: data/staff_gallery/
  • Supported formats:
    • *.json signature files
    • *.jpg, *.jpeg, *.png, *.bmp, *.webp sample crops
  • JSON example:
{
  "staff_id": "staff_001",
  "signature": [0.182, 0.244, 0.317]
}

Offline bundle:

  • Target host assumption: Ubuntu 24.04, Python 3.12, NVIDIA GPU compatible with the .108 runtime stack
  • Bundle script: bash scripts/package_bundle.sh
  • Bundle output: dist/store_dwell_alert_bundle_<date>.tar.gz
  • Bundle prerequisites before packaging:
    • place Linux wheels under wheelhouse/
    • place yolo11n.pt under weights/yolo11n.pt

Offline install on target host:

  1. Extract store_dwell_alert_bundle_<date>.tar.gz
  2. Edit scripts/run.sh and set RTSP_URL
  3. Run sudo bash scripts/install.sh
  4. The installer enables and starts store-dwell-alert.service

Optional service install:

  1. Run bash scripts/install_service.sh
  2. Start with sudo systemctl start store-dwell-alert.service

Docker image:

  • Required runtime weight in build context: weights/yolo11n.pt
  • Build: docker build -t store-dwell-alert:test .
  • Compose: docker compose up --build store-dwell-alert
  • Health: http://127.0.0.1:18081/api/manage/health
  • Default container entrypoint seeds config/local.yaml from config/config.example.yaml and then starts the management API
  • Persisted host paths:
    • ./config -> /app/config
    • ./data -> /app/data
    • ./logs -> /app/logs

中文离线部署说明

适用环境:

  • Ubuntu 24.04
  • Python 3.12
  • 已安装 NVIDIA 驱动,nvidia-smi 可用
  • 已安装 ffmpeg

离线包准备:

  • 成品包示例:store_dwell_alert_bundle_2026-04-16.tar.gz
  • 包内已经包含:
    • 项目源码
    • wheelhouse/ 离线依赖
    • weights/yolo11n.pt
    • scripts/install.sh
    • scripts/run.sh
    • scripts/install_service.sh

部署步骤:

  1. 把离线包传到目标机器
  2. 解压:
tar -xzf store_dwell_alert_bundle_2026-04-16.tar.gz
cd store_dwell_alert_bundle
  1. 执行离线安装:
bash scripts/install.sh
  1. 编辑运行脚本,至少改这几个变量:
    • RTSP_URL
    • CAMERA_ID
    • EVENT_SINK_PATH
vim scripts/run.sh
  1. 手工启动:
bash scripts/run.sh

常见输出位置:

  • 事件结果:logs/events.jsonl
  • 本地配置:config/local.yaml
  • 店员图库:data/staff_gallery/

如果需要做店员排除:

  • 把店员样本图放到 data/staff_gallery/
  • 或者放入对应的 *.json 特征文件

配置完成后的常驻运行:

  1. 安装服务:
bash scripts/install_service.sh
  1. 启动服务:
sudo systemctl start store-dwell-alert.service
  1. 查看状态:
sudo systemctl status store-dwell-alert.service
  1. 停止服务:
sudo systemctl stop store-dwell-alert.service
  1. 开机自启:
sudo systemctl enable store-dwell-alert.service

排查建议:

  • scripts/install.sh 失败时,先确认 python3.12ffmpegnvidia-smi 都存在
  • scripts/run.sh 失败时,先确认 RTSP_URL 已改成真实地址
  • 如果程序启动了但没有结果,先看 logs/events.jsonl 是否生成
  • 如果识别不到店员,先检查 data/staff_gallery/ 是否有有效样本