def compute_precision(kp_dist1, kp_dist2, correctness_threshold=3):
    """
        Compute the precision for a given threshold, averaged over the two images.
        kp_dist1 is the distance between the matched keypoints in img0 and the
        matched keypoints of img1 warped into img0. And vice-versa for kp_dist2.
    """
    precision = ((kp_dist1 <= correctness_threshold).mean()
                 + (kp_dist2 <= correctness_threshold).mean()) / 2
    
    return precision