naver / r2d2

Other
461 stars 86 forks source link

Could you release the calculation of matching performance ? Such as Repeatability and M-Scores #8

Closed GabbySuwichaya closed 4 years ago

GabbySuwichaya commented 4 years ago

Thank you for releasing your code implementation. I enjoy reading your paper, as well as having a very good impression about the performance of R2D2.

It seems that your method clearly outperforms the others in terms of MMA, and it is nice that you have picked the similar evaluation technique as D2-Net. This makes it clear that your method is among the best. However, recently many papers appear to employ similar measurements, yet with some minor differences tuned to their specific assumption.

Therefore, I would like to kindly ask for an implementation of how you calculate the Repeatability and M-Scores? It would be really helpful because lots of people can use it as a reference (at least in python version).

jerome-revaud commented 4 years ago

Hi @GabbySuwichaya

So in fact, the repeatability is calculated using the code from http://www.robots.ox.ac.uk/~vgg/research/affine/ (Detectors evaluation - Matlab files to compute the repeatability) with the maximum overlap error of 40%.

What you need to provide is the keypoints position and ellipse - I'm using circles that have their diameter corresponding to the patch size (= receptive field). For R2D2 I was using 32 pixels. ​​ By the way, i believe this matlab code is implemented in OpenCV as wells. The function is called evaluateFeatureDetector(...)

About the matching-score, I will try to release the code some day when I have time. But my implementation was pretty standard, I believe.

GabbySuwichaya commented 4 years ago

@jerome-revaud. Thanks so much for the information. I will looking forward to your update. :)

GabbySuwichaya commented 4 years ago

Hi @jerome-revaud, I have tried using the package.

However, I am stuck at producing the keypoints position and ellipse. The results are much lower so I think I might have made mistakes. Could you recommend the package that you used to provide the input to http://www.robots.ox.ac.uk/~vgg/research/affine/det_eval_files/repeatability.m.

jerome-revaud commented 4 years ago

Hi @GabbySuwichaya I'm so sorry, right now I don't really have the time to release the full evaluation code (very messy and scattered).

here is the function I was using to evaluate the repeatabilty. I was using the evaluateFeatureDetector function from OpenCV, but since it's only available in c++ I wrote a python wrapper to call it.

def compute_repeatability( H, kpts1, kpts2, imsize1, imsize2):
    from cv2_wrapper import calculateRepeatability
    kpts1[:,2] = 32 / kpts1[:,2]    # update keypoint diameter
    kpts2[:,2] = 32 / kpts2[:,2]
    """
    imsize = (height, width) tuple 
    H = 3x3 homography matrix
    kpts = Nx3 keypoints. Each row = (x, y, diameter)
    last param = threshold
    """
    rep = calculateRepeatability(imsize1, imsize2, np.float32(H), kpts1, kpts2, 0.4)
    return max(0, rep)
rllyryan commented 2 years ago

Hi @GabbySuwichaya I'm so sorry, right now I don't really have the time to release the full evaluation code (very messy and scattered).

here is the function I was using to evaluate the repeatabilty. I was using the evaluateFeatureDetector function from OpenCV, but since it's only available in c++ I wrote a python wrapper to call it.

def compute_repeatability( H, kpts1, kpts2, imsize1, imsize2):
    from cv2_wrapper import calculateRepeatability
    kpts1[:,2] = 32 / kpts1[:,2]    # update keypoint diameter
    kpts2[:,2] = 32 / kpts2[:,2]
    """
    imsize = (height, width) tuple 
    H = 3x3 homography matrix
    kpts = Nx3 keypoints. Each row = (x, y, diameter)
    last param = threshold
    """
    rep = calculateRepeatability(imsize1, imsize2, np.float32(H), kpts1, kpts2, 0.4)
    return max(0, rep)

Hi @jerome-revaud,

I chanced upon this issue on google, and it seems like you found a solution to making use of a certain function from OpenCV! Is it possible that you could share your python wrapper for the cv2.evaluateFeatureDetector() with me? I am currently trying to evaluate feature detectors on 2D grayscale robot maps for map merging (image stitching)!

Sorry for any inconvenience caused. Your work is greatly appreciated!