mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-10 12:51:11 +03:00
video/detect.py runs these for every frame: - get_cluster_candidates: used_boxes was a list with `in` membership tests inside the nested loop (O(n) per check). It is only ever membership-tested, so switching it to a set (O(1)) leaves output unchanged. - get_consolidated_object_detections: area(current_box) was recomputed on every inner-loop iteration though it is loop-invariant; hoist it to one call per outer detection. Both are bit-identical (verified against the previous implementations over randomized inputs). Measured in the release image, get_cluster_candidates on a frame of 30 detection boxes: 59.2 us -> 42.1 us (1.4x); the gain scales with the number of boxes per frame. Adds a partition-invariant test (every box index lands in exactly one cluster). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>