Reset Error
This commit is contained in:
1 parent
2437566712
commit
75587ddae2
3 files changed
+27
-11
No files matched your search
@@ -4,10 +4,11 @@
|
||||
|
||||
- **Edge AI counter**: RTSP camera → YOLO RKNN (NPU) → tracking → line-crossing → SQLite + JSON state → Flask dashboard.
|
||||
- **2 counter scripts**, only 1 deployed:
|
||||
- `counter_live.py` — Jetson TensorRT variant (CUDA, NOT used on RK3588).
|
||||
- `counter_live.py` — Jetson TensorRT artifact (CUDA, NOT used on RK3588).
|
||||
- **`counter_live_rknn_bytetrack.py`** — RK3588 with ByteTrack. **This is what systemd runs.** Reference for C++ port.
|
||||
- `batch_store.py` — shared SQLite persistence + batch state machine.
|
||||
- `counter_dashboard.py` — Flask dashboard on port 5000, same DB.
|
||||
- `recounting_dashboard.py` — Flask recounting dashboard on port 5002, consumes live + recount APIs.
|
||||
|
||||
## No build / test / lint
|
||||
|
||||
@@ -40,11 +41,13 @@ PYTHONNOUSERSITE=1 venv/bin/python counter_dashboard.py
|
||||
- Service user is **`root`**, not `jetson` (despite README saying otherwise).
|
||||
- Two systemd units: `bytetrack-counter.service` + `bytetrack-counter-dashboard.service`.
|
||||
- `counter_live.py` (TensorRT) is Jetson-only and won't work on RK3588.
|
||||
- **Reset flow**: `POST /api/reset` → deletes state JSON + touches `{SHM_DIR}/.reset`. `batch_store._check_reset_signal()` watches this marker and clears in-memory state on next crossing.
|
||||
|
||||
## Code conventions
|
||||
|
||||
- All config lives in `.env` (dotenv), read via `os.getenv()` at module top-level in each script.
|
||||
- The 3 counter scripts duplicate ~80% of each other (drawing helpers, batch loop, etc). Changes to logic may need replication across variants.
|
||||
- The 2 counter scripts share drawing/batch helpers. `counter_live_rknn_bytetrack.py` is the reference for C++ port.
|
||||
- `batch_store.py` has its own threading (cutoff watcher, batch timeout timer) — thread safety is via a single `state_lock`.
|
||||
- The dashboard re-creates DB tables on startup (`_ensure_db()`) independently from `batch_store.py`.
|
||||
- No formal version tracking exists anywhere in this codebase.
|
||||
- Dashboard template selectable via `DASHBOARD_TEMPLATE` env var — supports `dashboard.html`, `dashboard_lamborghini.html`, `dashboard_tesla.html`.
|
||||
@@ -91,17 +91,21 @@ api: GET /api/recent-batches?limit=N → [ {date, batch#, count, start/end, dura
|
||||
api: GET /api/available-dates → [ {date, total_count, total_batches} ]
|
||||
api: GET /api/export-daily-csv?days=N → .xlsx download (named csv, emits xlsx)
|
||||
api: GET /api/export-day-csv/<date> → .xlsx download (named csv, emits xlsx)
|
||||
api: POST /api/reset → delete STATE_FILE, touch {SHM_DIR}/.reset; returns 500 if SHM marker fails
|
||||
api: GET /api/live-video → MJPEG stream from shared-memory JPEG
|
||||
|
||||
### Recounting dashboard
|
||||
```
|
||||
api: GET / → recounting HTML
|
||||
api: GET / → recounting HTML (template via DASHBOARD_TEMPLATE env var)
|
||||
api: GET /api/live-progress → proxy to LIVE_API_URL:/api/current-batch
|
||||
api: GET /api/recount-progress → proxy to RECOUNT_API_URL:/api/current-batch
|
||||
api: GET /api/batch-result?file=<path> → parse `batch_NN_YYYYMMDD_HHmmSS.mp4`, query live API for count
|
||||
api: GET /api/mp4-files → [ {name, path, size, mtime} ... ]
|
||||
api: POST /api/start-recount {path} → configure go2rtc stream, return {stream_url}
|
||||
api: POST /api/stop-recount → tear down go2rtc stream
|
||||
api: GET /api/batch-result?file=<path> → parse batch num from filename, date from folder, query live API
|
||||
api: GET /api/mp4-files → folders grouped by date, files sorted by batch #
|
||||
api: GET /api/state → {streaming, file, file_name, stream_url, batch_number, batch_date}
|
||||
api: GET /api/proxy-stream → proxy MJPEG from RECOUNT_API_URL:/api/live-video (same-origin, avoids ORB)
|
||||
api: GET /api/download-mp4?file=<path> → download selected MP4
|
||||
api: POST /api/start-recount {path} → reset recount counter + launch ffmpeg RTSP, return {stream_url}
|
||||
api: POST /api/stop-recount → kill ffmpeg + clear current file
|
||||
```
|
||||
```
|
||||
|
||||
@@ -127,6 +131,7 @@ V16: NMS postprocessing → iou_thr=0.45, class-aware grouping, score > CONF
|
||||
V17: tracks pruned after TRACKED_PRUNE_SEC (default 300s) without update
|
||||
V18: .env missing → scripts fail at import (os.getenv falls back to defaults, may mismatch)
|
||||
V19: stream reconnect → reset motion detection state (prev_gray = None)
|
||||
V20: reset → delete STATE_FILE + touch {SHM_DIR}/.reset; batch_store._check_reset_signal() watches marker & clears in-memory state before next crossing
|
||||
```
|
||||
|
||||
## §T — Tasks
|
||||
@@ -137,14 +142,16 @@ T1|.|unify install paths — README/DEPLOY/setup-venv.sh/uninstall say `/opt/jet
|
||||
T2|.|zombie var RESET_COUNTERS_AT_CUTOFF — defined in .env.example, unused in code (confirmed by review)|
|
||||
T3|.|add version flag — no `--version` or git-derived version exists|
|
||||
T4|.|keep reference Python clean — counter_live.py is artifact; focus edits on counter_live_rknn_bytetrack.py as port source|
|
||||
T5|.|rename export routes — routes named `export-daily-csv` but emit `.xlsx`|I.flask
|
||||
T6|.|fix live-stream snapshot path — some scripts default `/dev/shm/jetson-counter/`, example says `bytetrack-counter`|
|
||||
T5|x|rename export routes — routes named `export-daily-csv` but emit `.xlsx`|I.flask
|
||||
T6|x|fix live-stream snapshot path — some scripts default `/dev/shm/jetson-counter/`, example says `bytetrack-counter`|
|
||||
T7|.|add dashboard health-check endpoint (no `/health` or `/api/status` exists)|
|
||||
T8|.|add model checks on startup — model class names ! validated against CLASS_AYAM/CLASS_TALENAN (TensorRT variant validates; RKNN variants do not)|
|
||||
T9|.|reset prev_gray on stream reconnect — stale gray ref causes crash or false motion|V19,B1
|
||||
T10|.|decay inf_ms toward 0 when inference skipped — stale display misleads operator|
|
||||
T11|x|reduce live-counter poll interval 2000→200ms for real-time feel|
|
||||
T12|x|add recounting dashboard — dual-API counter panels, MP4 browser, go2rtc streaming|
|
||||
T13|x|add template system — DASHBOARD_TEMPLATE env var selects dashboard.html|lamborghini|tesla|
|
||||
T14|x|harden reset API — separate SHM marker creation from state file cleanup; return 500 on SHM failure|V20
|
||||
```
|
||||
|
||||
## §B — Bugs
|
||||
|
||||
@@ -569,11 +569,17 @@ def api_reset():
|
||||
for p in paths:
|
||||
Path(p).unlink(missing_ok=True)
|
||||
Path(LIVE_STREAM_FRAME_PATH).unlink(missing_ok=True)
|
||||
except Exception as e:
|
||||
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Reset state file cleanup error: {e}")
|
||||
|
||||
try:
|
||||
Path(SHM_DIR).mkdir(parents=True, exist_ok=True)
|
||||
Path(f"{SHM_DIR}/.reset").touch()
|
||||
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Reset done — cleared {len(paths)} state file(s) + live frame + SHM reset flag")
|
||||
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Reset done — cleared {len(paths)} state file(s) + live frame + SHM reset flag at {SHM_DIR}/.reset")
|
||||
except Exception as e:
|
||||
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Reset error: {e}")
|
||||
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Reset SHM error: {e}")
|
||||
return jsonify({"success": False, "error": f"SHM reset failed: {e}"}), 500
|
||||
|
||||
return jsonify({"success": True, "message": "State + live frame cleared"})
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user