stefanopini/simple-HRNet

What is the pose tracking method used in this simple-HRNet

jellyfish1456 opened this issue · 1 comments

Hi~ Thank you for sharing this awesome job

I wanna ask that what is the tracking method you add in simple-HRNet?
Because the original method and paper seems to be no tracking method in it?

Thank you~

Hi!

It is a trivial tracking by detection algorithm, defined here:

simple-HRNet/misc/utils.py

Lines 382 to 425 in f4a8174

def find_person_id_associations(boxes, pts, prev_boxes, prev_pts, prev_person_ids, next_person_id=0,
pose_alpha=0.5, similarity_threshold=0.5, smoothing_alpha=0.):
"""
Find associations between previous and current skeletons and apply temporal smoothing.
It requires previous and current bounding boxes, skeletons, and previous person_ids.
Args:
boxes (:class:`np.ndarray`): current person bounding boxes
pts (:class:`np.ndarray`): current human joints
prev_boxes (:class:`np.ndarray`): previous person bounding boxes
prev_pts (:class:`np.ndarray`): previous human joints
prev_person_ids (:class:`np.ndarray`): previous person ids
next_person_id (int): the id that will be assigned to the next novel detected person
Default: 0
pose_alpha (float): parameter to weight between bounding box similarity and pose (oks) similarity.
pose_alpha * pose_similarity + (1 - pose_alpha) * bbox_similarity
Default: 0.5
similarity_threshold (float): lower similarity threshold to have a correct match between previous and
current detections.
Default: 0.5
smoothing_alpha (float): linear temporal smoothing filter. Set 0 to disable, 1 to keep the previous detection.
Default: 0.1
Returns:
(:class:`np.ndarray`, :class:`np.ndarray`, :class:`np.ndarray`):
A list with (boxes, pts, person_ids) where boxes and pts are temporally smoothed.
"""
bbox_similarity_matrix, pose_similarity_matrix = compute_similarity_matrices(boxes, prev_boxes, pts, prev_pts)
similarity_matrix = pose_similarity_matrix * pose_alpha + bbox_similarity_matrix * (1 - pose_alpha)
m = munkres.Munkres()
assignments = np.asarray(m.compute((1 - similarity_matrix).tolist())) # Munkres require a cost => 1 - similarity
person_ids = np.ones(len(pts), dtype=np.int32) * -1
for assignment in assignments:
if similarity_matrix[assignment[0], assignment[1]] > similarity_threshold:
person_ids[assignment[0]] = prev_person_ids[assignment[1]]
if smoothing_alpha:
boxes[assignment[0]] = (1 - smoothing_alpha) * boxes[assignment[0]] + smoothing_alpha * prev_boxes[assignment[1]]
pts[assignment[0]] = (1 - smoothing_alpha) * pts[assignment[0]] + smoothing_alpha * prev_pts[assignment[1]]
person_ids[person_ids == -1] = np.arange(next_person_id, next_person_id + np.sum(person_ids == -1))
return boxes, pts, person_ids

In short, it builds a similarity matrix between the previous and the current detections (based on bbox and pose similarity) then it associates previous and current detections with the Munkres algorithm to maximize the similarity of the associations.