feat(Q2): add heatmap route to cameras blueprint
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8c2a8ea1c5
commit
afc15a92fe
@ -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("/<camera_id>/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."""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user