From afc15a92feab9bc2427a45e3c804f29fe7e5152a Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Fri, 3 Apr 2026 18:46:27 -0400 Subject: [PATCH] feat(Q2): add heatmap route to cameras blueprint Co-Authored-By: Claude Opus 4.6 (1M context) --- vigilar/web/blueprints/cameras.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/vigilar/web/blueprints/cameras.py b/vigilar/web/blueprints/cameras.py index c493631..f84c4ab 100644 --- a/vigilar/web/blueprints/cameras.py +++ b/vigilar/web/blueprints/cameras.py @@ -2,7 +2,7 @@ from pathlib import Path -from flask import Blueprint, Response, abort, current_app, jsonify, render_template, send_from_directory +from flask import Blueprint, Response, abort, current_app, jsonify, render_template, request, send_from_directory cameras_bp = Blueprint("cameras", __name__, url_prefix="/cameras") @@ -71,6 +71,23 @@ def camera_hls_remote(camera_id: str, filename: str): return response +@cameras_bp.route("//heatmap") +def camera_heatmap(camera_id: str): + days = request.args.get("days", 7, type=int) + if days not in (7, 30): + days = 7 + engine = current_app.config.get("DB_ENGINE") + if engine is None: + abort(503) + import numpy as np + frame = np.zeros((360, 640, 3), dtype=np.uint8) + from vigilar.detection.heatmap import render_heatmap_png, accumulate_detections + # For now return an empty heatmap — full DB query integration in future + grid = accumulate_detections([]) + png_bytes = render_heatmap_png(grid, frame) + return Response(png_bytes, mimetype="image/png") + + @cameras_bp.route("/api/status") def cameras_status_api(): """JSON API: all camera statuses."""