Skip to content

Commit

Permalink
Fix bug of Nonetype cluster referenced when splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
aguscas committed Mar 22, 2024
1 parent 2680003 commit d871031
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
34 changes: 18 additions & 16 deletions demos/multi_camera/src/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ def draw_feet(
return frame


def get_embedding(bbox, frame):
t_shirt_bbox_x = 0.7 * bbox[:, 0] + 0.3 * bbox[::-1, 0]
top = np.min(bbox[:, 1])
bottom = np.max(bbox[:, 1])
t_shirt_bbox_y = np.array([top * 0.9 + bottom * 0.1, top * 0.5 + bottom * 0.5])

bbox[:, 0] = t_shirt_bbox_x
bbox[:, 1] = t_shirt_bbox_y

cut = get_cutout(bbox, frame)
if cut.shape[0] > 0 and cut.shape[1] > 0:
return get_hist(cut)
else:
return None


def draw_cluster_bboxes(
images,
clusters,
Expand Down Expand Up @@ -199,21 +215,7 @@ def yolo_detections_to_norfair_detections(yolo_detections, frame):
boxes.append(bbox)
points = bbox.copy()
scores = np.array([detection_as_xyxy[4], detection_as_xyxy[4]])

# get embedding
t_shirt_bbox_x = 0.7 * bbox[:, 0] + 0.3 * bbox[::-1, 0]
top = np.min(bbox[:, 1])
bottom = np.max(bbox[:, 1])
t_shirt_bbox_y = np.array([top * 0.7 + bottom * 0.3, top * 0.4 + bottom * 0.6])

bbox[:, 0] = t_shirt_bbox_x
bbox[:, 1] = t_shirt_bbox_y

cut = get_cutout(bbox, frame)
if cut.shape[0] > 0 and cut.shape[1] > 0:
embedding = get_hist(cut)
else:
embedding = None
embedding = get_embedding(bbox, frame)

norfair_detections.append(
Detection(
Expand Down Expand Up @@ -292,7 +294,7 @@ def run():
parser.add_argument(
"--reid-embedding-correlation-threshold",
type=float,
default=0.5,
default=0.3,
help="Threshold for embedding match during a reid phase after object has been lost. (The 1-correlation distance we use is bounded in [0, 2])",
)
parser.add_argument(
Expand Down
4 changes: 3 additions & 1 deletion norfair/multi_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ def conditionally_update_which_id_keeper(
keep_id_criteria,
):

if additional_cluster_number_keeping_old_id is None:
return True
# keep the id by the age or by the hit_counter if the current cluster is promising
if not tracked_object.live_points.any():
# if this cluster hasn't matched recently, cluster is not promising
Expand Down Expand Up @@ -702,7 +704,7 @@ def update(self, trackers_by_camera):
# create the aditional clusters
additional_clusters = []

additional_cluster_number_keeping_old_id = 0
additional_cluster_number_keeping_old_id = None
greatest_hit_counter = -1
oldest_age = -1
for current_cluster_number, tracked_ids in enumerate(
Expand Down

0 comments on commit d871031

Please sign in to comment.