- api/db/summary — overall totals - api/db/history — per-date rows - api/db/date/<date> — single date detail with per-camera breakdown - api/db/camera/<id> — all runs for a specific camera - api/db/location/<name> — per-location summary + history - API.md — full endpoint documentation with schema
3.0 KiB
3.0 KiB
Chicken Counter API
Base URL: http://<jetson-ip>:8080
Live Dashboard
GET /
Returns the dashboard HTML page.
GET /api/cameras
List cameras currently writing to /dev/shm.
{"cameras": ["CC1", "CC2", "CC3"]}
GET /shm/<camera_id>/stats.json
Live stats for the active pipeline.
{
"frame_index": 5120,
"inside_box_count": 42,
"total_entered_count": 1858,
"track_count": 99,
"backward_active": false,
"smoothed_speed": 4.3,
"count_events": 0,
"run_date": "2026-06-10"
}
GET /shm/<camera_id>/frame.jpg
Live JPEG frame from the active pipeline.
Database
All endpoints require the dashboard to be started with --db <path>. If no DB exists, endpoints return [] or {}.
GET /api/db/summary
Overall totals across all dates and locations.
{
"days": 12,
"locations": 2,
"total_runs": 48,
"total_chickens": 125000,
"total_hours": 8.5
}
GET /api/db/history
Per-date summary, newest first (max 50 rows).
[
{
"date": "2026-06-10",
"location": "kandang-atas",
"cams": 4,
"total": 5570,
"minutes": 40.2
}
]
GET /api/db/date/<date>
Detail for a specific date. Format: YYYY-MM-DD.
{
"date": "2026-06-10",
"total": {"total": 5570, "minutes": 40.2},
"cameras": [
{
"camera_id": "CC1",
"total_entered": 1500,
"frames_processed": 24800,
"elapsed_seconds": 600.5,
"stopped_reason": "backward",
"source_video": "kandang_1_camera_1_2026-06-10_120056.mp4",
"location": "kandang-atas"
}
]
}
GET /api/db/camera/<camera_id>
History for a specific camera across all dates (max 50 rows).
[
{
"date": "2026-06-10",
"location": "kandang-atas",
"total_entered": 1500,
"frames_processed": 24800,
"elapsed_seconds": 600.5,
"stopped_reason": "backward"
}
]
GET /api/db/location/<location>
Summary and history for a specific location.
{
"location": "kandang-atas",
"summary": {"days": 5, "total": 25000, "hours": 3.2},
"history": [
{
"date": "2026-06-10",
"cameras": "CC1, CC2, CC3, CC4",
"total": 5570,
"minutes": 40.2
}
]
}
Database Schema
CREATE TABLE batch_runs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
date TEXT NOT NULL,
location TEXT NOT NULL,
camera_id TEXT NOT NULL,
total_entered INTEGER NOT NULL DEFAULT 0,
frames_processed INTEGER NOT NULL DEFAULT 0,
elapsed_seconds REAL NOT NULL DEFAULT 0.0,
stopped_reason TEXT NOT NULL DEFAULT '',
source_video TEXT NOT NULL DEFAULT '',
generated_at TEXT NOT NULL DEFAULT '',
UNIQUE(date, location, camera_id)
);
Data is inserted automatically by the batch runner when location and db_path are configured in the batch YAML, or manually via:
python3 store_results.py output/counts_2026-06-10.json --location kandang-atas --db chicken_counts.db