remove max estimated speed

This commit is contained in:
Josh Hawkins 2024-12-22 16:46:25 -06:00
parent eaf362b424
commit 69b3ebcfc0
6 changed files with 12 additions and 33 deletions

View File

@ -323,7 +323,6 @@ def events_explore(limit: int = 10):
"description", "description",
"sub_label_score", "sub_label_score",
"average_estimated_speed", "average_estimated_speed",
"max_estimated_speed",
] ]
}, },
"event_count": label_counts[event.label], "event_count": label_counts[event.label],
@ -597,7 +596,6 @@ def events_search(request: Request, params: EventsSearchQueryParams = Depends())
"description", "description",
"sub_label_score", "sub_label_score",
"average_estimated_speed", "average_estimated_speed",
"max_estimated_speed",
] ]
} }

View File

@ -27,7 +27,6 @@ def should_update_db(prev_event: Event, current_event: Event) -> bool:
or prev_event["end_time"] != current_event["end_time"] or prev_event["end_time"] != current_event["end_time"]
or prev_event["average_estimated_speed"] or prev_event["average_estimated_speed"]
!= current_event["average_estimated_speed"] != current_event["average_estimated_speed"]
or prev_event["max_estimated_speed"] != current_event["max_estimated_speed"]
): ):
return True return True
return False return False
@ -213,7 +212,6 @@ class EventProcessor(threading.Thread):
"top_score": event_data["top_score"], "top_score": event_data["top_score"],
"attributes": attributes, "attributes": attributes,
"average_estimated_speed": event_data["average_estimated_speed"], "average_estimated_speed": event_data["average_estimated_speed"],
"max_estimated_speed": event_data["max_estimated_speed"],
"type": "object", "type": "object",
"max_severity": event_data.get("max_severity"), "max_severity": event_data.get("max_severity"),
}, },

View File

@ -65,7 +65,6 @@ class TrackedObject:
self.speed_history = [] self.speed_history = []
self.current_estimated_speed = 0 self.current_estimated_speed = 0
self.average_estimated_speed = 0 self.average_estimated_speed = 0
self.max_estimated_speed = 0
self.velocity_angle = 0 self.velocity_angle = 0
self.previous = self.to_dict() self.previous = self.to_dict()
@ -208,7 +207,7 @@ class TrackedObject:
f"Camera: {self.camera_config.name}, zone: {name}, tracked object ID: {self.obj_data['id']}, pixel velocity: {str(tuple(np.round(self.obj_data['estimate_velocity']).flatten().astype(int)))} estimated speed: {self.current_estimated_speed:.1f}" f"Camera: {self.camera_config.name}, zone: {name}, tracked object ID: {self.obj_data['id']}, pixel velocity: {str(tuple(np.round(self.obj_data['estimate_velocity']).flatten().astype(int)))} estimated speed: {self.current_estimated_speed:.1f}"
) )
if self.active: if self.active and name in self.current_zones:
# only keep the last 10 speeds # only keep the last 10 speeds
if len(self.speed_history) > 10: if len(self.speed_history) > 10:
self.speed_history = self.speed_history[-10:] self.speed_history = self.speed_history[-10:]
@ -217,9 +216,6 @@ class TrackedObject:
self.speed_history self.speed_history
) )
if self.current_estimated_speed > self.max_estimated_speed:
self.max_estimated_speed = self.current_estimated_speed
# update loitering status # update loitering status
self.pending_loitering = in_loitering_zone self.pending_loitering = in_loitering_zone
@ -303,7 +299,6 @@ class TrackedObject:
"max_severity": self.max_severity, "max_severity": self.max_severity,
"current_estimated_speed": self.current_estimated_speed, "current_estimated_speed": self.current_estimated_speed,
"average_estimated_speed": self.average_estimated_speed, "average_estimated_speed": self.average_estimated_speed,
"max_estimated_speed": self.max_estimated_speed,
"velocity_angle": self.velocity_angle, "velocity_angle": self.velocity_angle,
} }

View File

@ -4,7 +4,15 @@ import numpy as np
def order_points_clockwise(points): def order_points_clockwise(points):
points = np.array(points) """
Ensure points are sorted in clockwise order starting from the top left
:param points: Array of zone corner points in pixel coordinates
:return: Ordered list of points
"""
if not isinstance(points, np.ndarray):
points = np.array(points)
centroid = np.mean(points, axis=0) centroid = np.mean(points, axis=0)
angles = np.arctan2(points[:, 1] - centroid[1], points[:, 0] - centroid[0]) angles = np.arctan2(points[:, 1] - centroid[1], points[:, 0] - centroid[0])
@ -26,7 +34,7 @@ def create_ground_plane(zone_points, distances):
""" """
Create a ground plane that accounts for perspective distortion using real-world dimensions for each side of the zone. Create a ground plane that accounts for perspective distortion using real-world dimensions for each side of the zone.
:param zone_points: Array of zone corner points in pixel coordinates in circular order :param zone_points: Array of zone corner points in pixel coordinates
[[x1, y1], [x2, y2], [x3, y3], [x4, y4]] [[x1, y1], [x2, y2], [x3, y3], [x4, y4]]
:param distances: Real-world dimensions ordered by A, B, C, D :param distances: Real-world dimensions ordered by A, B, C, D
:return: Function that calculates real-world distance per pixel at any coordinate :return: Function that calculates real-world distance per pixel at any coordinate

View File

@ -328,18 +328,6 @@ function ObjectDetailsTab({
} }
}, [search]); }, [search]);
const maxEstimatedSpeed = useMemo(() => {
if (!search || !search.data?.max_estimated_speed) {
return undefined;
}
if (search.data?.max_estimated_speed != 0) {
return search.data?.max_estimated_speed.toFixed(1);
} else {
return undefined;
}
}, [search]);
const updateDescription = useCallback(() => { const updateDescription = useCallback(() => {
if (!search) { if (!search) {
return; return;
@ -451,7 +439,7 @@ function ObjectDetailsTab({
{score}%{subLabelScore && ` (${subLabelScore}%)`} {score}%{subLabelScore && ` (${subLabelScore}%)`}
</div> </div>
</div> </div>
{(averageEstimatedSpeed || maxEstimatedSpeed) && ( {averageEstimatedSpeed && (
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<div className="text-sm text-primary/40">Estimated Speeds</div> <div className="text-sm text-primary/40">Estimated Speeds</div>
<div className="flex flex-col space-y-0.5 text-sm"> <div className="flex flex-col space-y-0.5 text-sm">
@ -462,13 +450,6 @@ function ObjectDetailsTab({
<span className="text-primary/40">(average)</span> <span className="text-primary/40">(average)</span>
</div> </div>
)} )}
{maxEstimatedSpeed && (
<div>
{maxEstimatedSpeed}{" "}
{config?.ui.unit_system == "imperial" ? "mph" : "kph"}{" "}
<span className="text-primary/40">(maximum)</span>
</div>
)}
</div> </div>
</div> </div>
)} )}

View File

@ -56,7 +56,6 @@ export type SearchResult = {
type: "object" | "audio" | "manual"; type: "object" | "audio" | "manual";
description?: string; description?: string;
average_estimated_speed: number; average_estimated_speed: number;
max_estimated_speed: number;
}; };
}; };