def _track_by_oks(res, results_last, thr, sigmas=None):
    """Get track id using OKS tracking greedily."""
    keypoint = np.concatenate((res.pred_instances.keypoints,
                               res.pred_instances.keypoint_scores[:, :, None]),
                              axis=2)
    keypoint = np.squeeze(keypoint, axis=0).reshape((-1))
    area = np.squeeze(res.pred_instances.areas, axis=0)
    max_index = -1
    match_result = {}

    if len(results_last) == 0:
        return -1, results_last, match_result

    keypoints_last = np.array([
        np.squeeze(
            np.concatenate(
                (res_last.pred_instances.keypoints,
                 res_last.pred_instances.keypoint_scores[:, :, None]),
                axis=2),
            axis=0).reshape((-1)) for res_last in results_last
    ])
    area_last = np.array([
        np.squeeze(res_last.pred_instances.areas, axis=0)
        for res_last in results_last
    ])

    oks_score = oks_iou(
        keypoint, keypoints_last, area, area_last, sigmas=sigmas)

    max_index = np.argmax(oks_score)

    if oks_score[max_index] > thr:
        track_id = results_last[max_index].track_id
        match_result = results_last[max_index]
        del results_last[max_index]
    else:
        track_id = -1

    return track_id, results_last, match_result
Get track id using OKS tracking greedily.
mmpose/mmpose/apis/inference_tracking.py