Skip to content

Commit

Permalink
Keep id in cluster with greatest hit_counter when splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
Agustín Castro committed Mar 9, 2024
1 parent 6eb462e commit 7c187a2
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions norfair/multi_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,11 @@ def update(self, trackers_by_camera):

# create the aditional clusters
additional_clusters = []
cluster_number_with_oldest_tracker = None
oldest_tracker_age_in_additional_cluster = -1

# we will keep the
cluster_number_with_greatest_hit_counter = None
greatest_hit_counter = -1
oldest_age_in_that_cluster = -1
for current_cluster_number, tracked_ids in enumerate(
intersection_matrix_ids[cluster_number]
):
Expand All @@ -686,13 +689,31 @@ def update(self, trackers_by_camera):
new_cluster.reid_hit_counter[camera_name] = 0

if (
oldest_tracker_age_in_additional_cluster
< cluster.tracked_objects[camera_name].age
):
oldest_tracker_age_in_additional_cluster = (
cluster.tracked_objects[camera_name].age
(
greatest_hit_counter
< cluster.tracked_objects[camera_name].hit_counter
)
cluster_number_with_oldest_tracker = (
or (
(
greatest_hit_counter
== cluster.tracked_objects[
camera_name
].hit_counter
)
and (
oldest_age_in_that_cluster
< cluster.tracked_objects[camera_name].age
)
)
or (cluster_number_with_greatest_hit_counter is None)
):
greatest_hit_counter = cluster.tracked_objects[
camera_name
].hit_counter
oldest_age_in_that_cluster = cluster.tracked_objects[
camera_name
].age
cluster_number_with_greatest_hit_counter = (
current_cluster_number
)

Expand All @@ -701,14 +722,16 @@ def update(self, trackers_by_camera):
additional_clusters.append(None)

cluster.tracked_ids.extend(
additional_clusters[cluster_number_with_oldest_tracker].tracked_ids
additional_clusters[
cluster_number_with_greatest_hit_counter
].tracked_ids
)
cluster.tracked_objects = additional_clusters[
cluster_number_with_oldest_tracker
cluster_number_with_greatest_hit_counter
].tracked_objects
cluster.reid_hit_counter.update(
additional_clusters[
cluster_number_with_oldest_tracker
cluster_number_with_greatest_hit_counter
].reid_hit_counter
)

Expand All @@ -729,7 +752,10 @@ def update(self, trackers_by_camera):
new_cluster.tracked_ids
)

if current_cluster_number == cluster_number_with_oldest_tracker:
if (
current_cluster_number
== cluster_number_with_greatest_hit_counter
):
intersection_matrix_ids[
cluster_number
] = new_row_interesection_ids
Expand Down

0 comments on commit 7c187a2

Please sign in to comment.