# On score metrics for keypoint-descriptors

I am matching a lot of subwindows from a scene image to a model image with a Bruteforce Matcher and hamming distance. I want to find in which subwindow there is the highest probability that the object from the model image is present, and as a bonus I would like to know if nothing is found. (There are some reasons why I am sub windowing the scene, this is related to the fact there are often multiple possible matches and worst, multiple possible *partial* matches that must be rejected)

So I prune the matches result with a simple threshold, then I compute the homography of each subwindow with findHomography with RANSAC. This function has an optional output mask, let's call it the "homography_mask". Here is how it works.

Right now, I have two score metrics which each give me somewhat good results but I have the feeling that they could be improved. (in pseudocode)

```
1. score = countNonZero(homography_mask); // The absolute number of inliers as computed by the homography
2. score = countNonZero(homography_mask) / (lenght(homography_mask) -
countNonZero(homography_mask)); // The number of inliers divided by the number of outliers
```

With method #2, the ratio is inducing false positives because there no sense of the total number of matches in a given subwindow, so a relatively low number of matches may give a relatively high ratio. On the other hand I cannot readily discard lower number of matches;

With method #1, the absolute number of inliers matches doesn't give a sense of how much outliers there were. Worst, a subwindow could, by chance (experimentally verified), have a higher number of inliers than the correct subwindow even if only say half of the model object is present.

Right now, I am building an hybrid version of both metrics, but if anyone has a good idea I am a taker!