Cleanup resetting tracked object activity

This commit is contained in:
Nicolas Mowen 2025-05-15 13:12:11 -06:00
parent ffcf3c0692
commit 1fcadb09b0
3 changed files with 24 additions and 22 deletions

View File

@ -1570,10 +1570,29 @@ class LicensePlateProcessingMixin:
def handle_request(self, topic, request_data) -> dict[str, Any] | None: def handle_request(self, topic, request_data) -> dict[str, Any] | None:
return return
def expire_object(self, object_id: str, camera: str): def lpr_expire(self, object_id: str, camera: str):
print(
f"expiring {self.detected_license_plates} and we have cars {self.camera_current_cars}"
)
if object_id in self.detected_license_plates: if object_id in self.detected_license_plates:
self.detected_license_plates.pop(object_id) self.detected_license_plates.pop(object_id)
if object_id in self.camera_current_cars.get(camera, []):
self.camera_current_cars[camera].remove(object_id)
if len(self.camera_current_cars[camera]) == 0:
self.requestor.send_data(
"tracked_object_update",
json.dumps(
{
"type": TrackedObjectUpdateTypesEnum.lpr,
"name": None,
"plate": None,
"camera": camera,
}
),
)
class CTCDecoder: class CTCDecoder:
""" """

View File

@ -293,10 +293,11 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
if camera not in self.camera_current_people: if camera not in self.camera_current_people:
self.camera_current_people[camera] = [] self.camera_current_people[camera] = []
self.camera_current_people[camera].append(id)
self.person_face_history[id].append( self.person_face_history[id].append(
(sub_label, score, face_frame.shape[0] * face_frame.shape[1]) (sub_label, score, face_frame.shape[0] * face_frame.shape[1])
) )
self.camera_current_people[camera].append(id)
(weighted_sub_label, weighted_score) = self.weighted_average( (weighted_sub_label, weighted_score) = self.weighted_average(
self.person_face_history[id] self.person_face_history[id]
) )

View File

@ -1,6 +1,5 @@
"""Handle processing images for face detection and recognition.""" """Handle processing images for face detection and recognition."""
import json
import logging import logging
from typing import Any from typing import Any
@ -15,7 +14,6 @@ from frigate.data_processing.common.license_plate.mixin import (
from frigate.data_processing.common.license_plate.model import ( from frigate.data_processing.common.license_plate.model import (
LicensePlateModelRunner, LicensePlateModelRunner,
) )
from frigate.types import TrackedObjectUpdateTypesEnum
from ..types import DataProcessorMetrics from ..types import DataProcessorMetrics
from .api import RealTimeProcessorApi from .api import RealTimeProcessorApi
@ -55,21 +53,5 @@ class LicensePlateRealTimeProcessor(LicensePlateProcessingMixin, RealTimeProcess
return return
def expire_object(self, object_id: str, camera: str): def expire_object(self, object_id: str, camera: str):
if object_id in self.detected_license_plates: """Expire lpr objects."""
self.detected_license_plates.pop(object_id) self.lpr_expire(object_id, camera)
if object_id in self.camera_current_cars.get(camera, []):
self.camera_current_cars[camera].remove(object_id)
if len(self.camera_current_cars[camera]) == 0:
self.requestor.send_data(
"tracked_object_update",
json.dumps(
{
"type": TrackedObjectUpdateTypesEnum.lpr,
"name": None,
"plate": None,
"camera": camera,
}
),
)