Frame time fix (#17816)

* Don't update thumbnail/snapshot if frame is not in the frame cache

This follows up on changes originally made in https://github.com/blakeblackshear/frigate/pull/17671 - it is possible that is_better_thumbnail is true but the frame_time for the object is not the same as the current_frame_time. So rather than checking the frame cache, this change will only update the thumbnail_data when the two frame time values are the same.

* add camera name to debug log
This commit is contained in:
Josh Hawkins 2025-04-21 17:36:10 -05:00 committed by GitHub
parent d5f9153c94
commit 6936d33172
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -138,45 +138,35 @@ class TrackedObject:
if not self.false_positive and has_valid_frame:
# determine if this frame is a better thumbnail
if self.thumbnail_data is None or (
better_thumb := is_better_thumbnail(
self.obj_data["label"],
self.thumbnail_data,
obj_data,
self.camera_config.frame_shape,
)
if self.thumbnail_data is None or is_better_thumbnail(
self.obj_data["label"],
self.thumbnail_data,
obj_data,
self.camera_config.frame_shape,
):
# use the current frame time if the object's frame time isn't in the frame cache
selected_frame_time = (
current_frame_time
if obj_data["frame_time"] not in self.frame_cache.keys()
else obj_data["frame_time"]
)
if (
obj_data["frame_time"] not in self.frame_cache.keys()
and not better_thumb
):
logger.warning(
f"Frame time {obj_data['frame_time']} not in frame cache, using current frame time {selected_frame_time}"
if obj_data["frame_time"] == current_frame_time:
self.thumbnail_data = {
"frame_time": obj_data["frame_time"],
"box": obj_data["box"],
"area": obj_data["area"],
"region": obj_data["region"],
"score": obj_data["score"],
"attributes": obj_data["attributes"],
"current_estimated_speed": self.current_estimated_speed,
"velocity_angle": self.velocity_angle,
"path_data": self.path_data,
"recognized_license_plate": obj_data.get(
"recognized_license_plate"
),
"recognized_license_plate_score": obj_data.get(
"recognized_license_plate_score"
),
}
thumb_update = True
else:
logger.debug(
f"{self.camera_config.name}: Object frame time {obj_data['frame_time']} is not equal to the current frame time {current_frame_time}, not updating thumbnail"
)
self.thumbnail_data = {
"frame_time": selected_frame_time,
"box": obj_data["box"],
"area": obj_data["area"],
"region": obj_data["region"],
"score": obj_data["score"],
"attributes": obj_data["attributes"],
"current_estimated_speed": self.current_estimated_speed,
"velocity_angle": self.velocity_angle,
"path_data": self.path_data,
"recognized_license_plate": obj_data.get(
"recognized_license_plate"
),
"recognized_license_plate_score": obj_data.get(
"recognized_license_plate_score"
),
}
thumb_update = True
# check zones
current_zones = []