Five components that ship as one product:
- behavision/ the recognition engine. RTSP ingest, YuNet detection, IoU
tracking, ArcFace embeddings, a FAISS/SQLite gallery, and a
FastAPI dashboard. Identity is decided once per TRACK from an
average of at least three embeddings, never per frame.
- agent/ the Go edge agent: supervises the engine, holds a durable
spool, and drains it to MQTT. Nothing is acked before the
broker confirms.
- desktop/ the shop PC application (Wails + React + tray).
- server/ the cloud API, MQTT consumer, reports and assistant.
- web/ platform.loyaly.ai, the head-office app, embedded in the
server binary.
The gallery stores 512-float embeddings and timestamps - no images unless
`app.store_faces` is switched on. Those embeddings are biometric personal
data under GDPR and India's DPDP: template inversion reconstructs a
recognisable face from an ArcFace vector, so data/behavision.db is treated
as a biometric database and DELETE /api/visitors/{id} is a real erasure.
CLAUDE.md carries the reasoning behind every non-obvious decision here,
including the ones that were measured and the ones that were wrong first.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HViLj9gYNRtSr7YVZmW5sn
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
import numpy as np
|
|
|
|
from behavision.detection import Detection
|
|
from behavision.tracking import IouTracker
|
|
|
|
KPS = np.zeros((5, 2), dtype=np.float32)
|
|
|
|
|
|
def det(box, score=0.9, quality=0.5):
|
|
return Detection(box=box, kps=KPS, score=score, quality=quality)
|
|
|
|
|
|
def test_same_face_keeps_one_track():
|
|
tracker = IouTracker(iou_threshold=0.3, max_misses=3)
|
|
for i in range(5):
|
|
active, ended = tracker.update([det((100 + i, 100, 200 + i, 200))])
|
|
assert len(active) == 1
|
|
assert active[0].hits == 5
|
|
assert not ended
|
|
|
|
|
|
def test_two_faces_two_tracks():
|
|
tracker = IouTracker()
|
|
active, _ = tracker.update([det((0, 0, 50, 50)), det((300, 300, 350, 350))])
|
|
assert len(active) == 2
|
|
assert active[0].id != active[1].id
|
|
|
|
|
|
def test_track_ends_after_max_misses():
|
|
tracker = IouTracker(max_misses=2)
|
|
tracker.update([det((0, 0, 50, 50))])
|
|
ended_all = []
|
|
for _ in range(4):
|
|
_, ended = tracker.update([])
|
|
ended_all += ended
|
|
assert len(ended_all) == 1
|
|
assert not tracker.tracks
|
|
|
|
|
|
def test_best_quality_is_retained():
|
|
tracker = IouTracker()
|
|
tracker.update([det((0, 0, 50, 50), quality=0.8)])
|
|
active, _ = tracker.update([det((1, 1, 51, 51), quality=0.3)])
|
|
assert active[0].quality == 0.3
|
|
assert active[0].best_quality == 0.8
|