Autotracking: reset motion estimator (#7129)

* reset motion estimator after returning to preset

* small tweaks and a bugfix
This commit is contained in:
Josh Hawkins
2023-07-13 05:32:51 -05:00
committed by GitHub
parent 7a2d09dc35
commit c9254b256a
4 changed files with 96 additions and 48 deletions

View File

@@ -67,7 +67,9 @@ class NorfairTracker(ObjectTracker):
self.max_disappeared = config.detect.max_disappeared
self.camera_config = config
self.detect_config = config.detect
self.ptz_metrics = ptz_metrics
self.ptz_autotracker_enabled = ptz_metrics["ptz_autotracker_enabled"]
self.ptz_motion_estimator = {}
self.camera_name = config.name
self.track_id_map = {}
# TODO: could also initialize a tracker per object class if there
@@ -79,7 +81,9 @@ class NorfairTracker(ObjectTracker):
hit_counter_max=self.max_disappeared,
)
if self.ptz_autotracker_enabled.value:
self.ptz_motion_estimator = PtzMotionEstimator(config, ptz_metrics)
self.ptz_motion_estimator = PtzMotionEstimator(
self.camera_config, self.ptz_metrics
)
def register(self, track_id, obj):
rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
@@ -244,6 +248,12 @@ class NorfairTracker(ObjectTracker):
coord_transformations = None
if self.ptz_autotracker_enabled.value:
# we must have been enabled by mqtt, so set up the estimator
if not self.ptz_motion_estimator:
self.ptz_motion_estimator = PtzMotionEstimator(
self.camera_config, self.ptz_metrics
)
coord_transformations = self.ptz_motion_estimator.motion_estimator(
detections, frame_time, self.camera_name
)