ImprovedMotionDetector.detect() runs on every frame of every camera. With
improve_contrast enabled (the default), it called np.percentile twice per
frame to find the 4th/96th percentile of the resized motion frame, each call
partitioning the whole array.
Compute both percentiles from a single 256-bin uint8 histogram instead. The
result is bit-identical to int(np.percentile(...)) (the values are used as
uint8 contrast bounds); only the array is now scanned once rather than
partitioned twice.
Measured in the release image on a height-100 motion frame (the default):
np.percentile x2 ~225 us -> histogram ~11 us per frame (~20x). This runs per
frame per camera, so it scales with camera count.
Adds a test asserting the histogram percentiles equal numpy's across uniform,
low-contrast, single-color and bimodal frames.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* CenterFocusString icon
* Add CenterFocusString to multiselect
* Rename CenterFocusString.jsx
* Rename icon and make it smaller
* Rename icon
* Fix lint and use icon
for speech
* remove unused vars
* Remove unused import