mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-17 21:58:22 +03:00
fix: inverted condition causes division by zero in velocity direction check (#22470)
The cosine similarity calculation is guarded by: if not np.any(np.linalg.norm(velocities, axis=1)) This enters the block when ALL velocity norms are zero, then divides by those zero norms. The condition should check that all norms are non-zero before computing cosine similarity: if np.all(np.linalg.norm(velocities, axis=1)) Also fixes debug log that shows average_velocity[0] for both x and y velocity components (second should be average_velocity[1]).
This commit is contained in:
parent
e80da2b297
commit
6d7b1ce384
@ -901,7 +901,7 @@ class PtzAutoTracker:
|
||||
# Check direction difference
|
||||
velocities = np.round(velocities)
|
||||
invalid_dirs = False
|
||||
if not np.any(np.linalg.norm(velocities, axis=1)):
|
||||
if np.all(np.linalg.norm(velocities, axis=1)):
|
||||
cosine_sim = np.dot(velocities[0], velocities[1]) / (
|
||||
np.linalg.norm(velocities[0]) * np.linalg.norm(velocities[1])
|
||||
)
|
||||
@ -1067,7 +1067,7 @@ class PtzAutoTracker:
|
||||
f"{camera}: Zoom test: below dimension threshold: {below_dimension_threshold} width: {bb_right - bb_left}, max width: {camera_width * (self.zoom_factor[camera] + 0.1)}, height: {bb_bottom - bb_top}, max height: {camera_height * (self.zoom_factor[camera] + 0.1)}"
|
||||
)
|
||||
logger.debug(
|
||||
f"{camera}: Zoom test: below velocity threshold: {below_velocity_threshold} velocity x: {abs(average_velocity[0])}, x threshold: {velocity_threshold_x}, velocity y: {abs(average_velocity[0])}, y threshold: {velocity_threshold_y}"
|
||||
f"{camera}: Zoom test: below velocity threshold: {below_velocity_threshold} velocity x: {abs(average_velocity[0])}, x threshold: {velocity_threshold_x}, velocity y: {abs(average_velocity[1])}, y threshold: {velocity_threshold_y}"
|
||||
)
|
||||
logger.debug(f"{camera}: Zoom test: at max zoom: {at_max_zoom}")
|
||||
logger.debug(f"{camera}: Zoom test: at min zoom: {at_min_zoom}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user