ORB feature match and “degenerate” Hamming distance












0















I am trying to find matching features in two big images (orthophotos covering hundreds of acres at 5 cm resolution) so I can register them. I find many thousands of keypoints in the two images, and then I find cross-checked matches, sort them and take the best ~30% matches. Geographically, the matches are not very good. Here is the code:



def find_matches(key1, dsc1, key2, dsc2):

#Match features - this uses the BFmatcher class, I use it to take advantage of crossCheck
matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = matcher.match(dsc1, dsc2)


# Sort matches by score
matches.sort(key=lambda x:x.distance, reverse=False)

# Remove not so good matches Is this needed when we do geo sort?
print("cross-check matches = ", len(matches))
numGoodMatches = int(len(matches) * GOOD_MATCH_PERCENT)
matches = matches[:numGoodMatches]

# Draw top matches
imMatches = cv2.drawMatches(refimgGray, key1, imgGray, key2, matches, None, flags=4,)
cv2.imwrite(r"C:AV GISmatches.jpg", imMatches)

return matches


When I look at a plot of the distance associated with the sorted matches I see many Hamming distance values of the same value:
Graph of match distances - x-axis is sorted match number, y-axis is Hamming distance. It looks like stair steps, with many matches sharing the same Hamming distance.



I am adding more filtering of matches to ensure they are geographically close, but I think I am forgoing many good matches just because they are "invisible" to the matcher.



Here is my question:
Can anyone explain how matches are decided when there is just one score to evaluate, and it is not unique? I tried the same thing with a single camera image (orders of magnitude smaller in number of pixels) and even then, the distance scores were not unique. Am I misunderstanding how these matches are found and used?



ADDED - here is a graph of best keypoint matches colored by geographic distances. graph of best keypoint matches colored by geographic distances










share|improve this question

























  • typically after matching, you should use some kind of higher algorithm to verify matches, like computing a homography with RANSAC, finding inliers and outliers, or to compute a fundamental matrix, detecting inliers and outliers. You could write your own matcher, which duplicates keypoints if there are many "best matches" for a single keypoint. But I'm not sure how exactly you mean those "same valued" distances. It is possible that there are 4 keypoints: A1, A2, B1, B2 in images 1 and 2 and that A1 has the same distance to A2 as B1 has to B2, but that the distance between A1 and B2 is bigger.

    – Micka
    Nov 22 '18 at 9:17











  • Thanks for your comment - When I look at my sorted matches, there can be ~100 matches with a Hamming distance of 14. How those 100 pairs are matched up - I am not sure. It looks kind of random to me, and so very few of those random matches seem to correspond to geographic matches. I'm going to think more carefully about your example at the comment. Thanks again.

    – Andy Kellett
    Nov 23 '18 at 17:13


















0















I am trying to find matching features in two big images (orthophotos covering hundreds of acres at 5 cm resolution) so I can register them. I find many thousands of keypoints in the two images, and then I find cross-checked matches, sort them and take the best ~30% matches. Geographically, the matches are not very good. Here is the code:



def find_matches(key1, dsc1, key2, dsc2):

#Match features - this uses the BFmatcher class, I use it to take advantage of crossCheck
matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = matcher.match(dsc1, dsc2)


# Sort matches by score
matches.sort(key=lambda x:x.distance, reverse=False)

# Remove not so good matches Is this needed when we do geo sort?
print("cross-check matches = ", len(matches))
numGoodMatches = int(len(matches) * GOOD_MATCH_PERCENT)
matches = matches[:numGoodMatches]

# Draw top matches
imMatches = cv2.drawMatches(refimgGray, key1, imgGray, key2, matches, None, flags=4,)
cv2.imwrite(r"C:AV GISmatches.jpg", imMatches)

return matches


When I look at a plot of the distance associated with the sorted matches I see many Hamming distance values of the same value:
Graph of match distances - x-axis is sorted match number, y-axis is Hamming distance. It looks like stair steps, with many matches sharing the same Hamming distance.



I am adding more filtering of matches to ensure they are geographically close, but I think I am forgoing many good matches just because they are "invisible" to the matcher.



Here is my question:
Can anyone explain how matches are decided when there is just one score to evaluate, and it is not unique? I tried the same thing with a single camera image (orders of magnitude smaller in number of pixels) and even then, the distance scores were not unique. Am I misunderstanding how these matches are found and used?



ADDED - here is a graph of best keypoint matches colored by geographic distances. graph of best keypoint matches colored by geographic distances










share|improve this question

























  • typically after matching, you should use some kind of higher algorithm to verify matches, like computing a homography with RANSAC, finding inliers and outliers, or to compute a fundamental matrix, detecting inliers and outliers. You could write your own matcher, which duplicates keypoints if there are many "best matches" for a single keypoint. But I'm not sure how exactly you mean those "same valued" distances. It is possible that there are 4 keypoints: A1, A2, B1, B2 in images 1 and 2 and that A1 has the same distance to A2 as B1 has to B2, but that the distance between A1 and B2 is bigger.

    – Micka
    Nov 22 '18 at 9:17











  • Thanks for your comment - When I look at my sorted matches, there can be ~100 matches with a Hamming distance of 14. How those 100 pairs are matched up - I am not sure. It looks kind of random to me, and so very few of those random matches seem to correspond to geographic matches. I'm going to think more carefully about your example at the comment. Thanks again.

    – Andy Kellett
    Nov 23 '18 at 17:13
















0












0








0








I am trying to find matching features in two big images (orthophotos covering hundreds of acres at 5 cm resolution) so I can register them. I find many thousands of keypoints in the two images, and then I find cross-checked matches, sort them and take the best ~30% matches. Geographically, the matches are not very good. Here is the code:



def find_matches(key1, dsc1, key2, dsc2):

#Match features - this uses the BFmatcher class, I use it to take advantage of crossCheck
matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = matcher.match(dsc1, dsc2)


# Sort matches by score
matches.sort(key=lambda x:x.distance, reverse=False)

# Remove not so good matches Is this needed when we do geo sort?
print("cross-check matches = ", len(matches))
numGoodMatches = int(len(matches) * GOOD_MATCH_PERCENT)
matches = matches[:numGoodMatches]

# Draw top matches
imMatches = cv2.drawMatches(refimgGray, key1, imgGray, key2, matches, None, flags=4,)
cv2.imwrite(r"C:AV GISmatches.jpg", imMatches)

return matches


When I look at a plot of the distance associated with the sorted matches I see many Hamming distance values of the same value:
Graph of match distances - x-axis is sorted match number, y-axis is Hamming distance. It looks like stair steps, with many matches sharing the same Hamming distance.



I am adding more filtering of matches to ensure they are geographically close, but I think I am forgoing many good matches just because they are "invisible" to the matcher.



Here is my question:
Can anyone explain how matches are decided when there is just one score to evaluate, and it is not unique? I tried the same thing with a single camera image (orders of magnitude smaller in number of pixels) and even then, the distance scores were not unique. Am I misunderstanding how these matches are found and used?



ADDED - here is a graph of best keypoint matches colored by geographic distances. graph of best keypoint matches colored by geographic distances










share|improve this question
















I am trying to find matching features in two big images (orthophotos covering hundreds of acres at 5 cm resolution) so I can register them. I find many thousands of keypoints in the two images, and then I find cross-checked matches, sort them and take the best ~30% matches. Geographically, the matches are not very good. Here is the code:



def find_matches(key1, dsc1, key2, dsc2):

#Match features - this uses the BFmatcher class, I use it to take advantage of crossCheck
matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = matcher.match(dsc1, dsc2)


# Sort matches by score
matches.sort(key=lambda x:x.distance, reverse=False)

# Remove not so good matches Is this needed when we do geo sort?
print("cross-check matches = ", len(matches))
numGoodMatches = int(len(matches) * GOOD_MATCH_PERCENT)
matches = matches[:numGoodMatches]

# Draw top matches
imMatches = cv2.drawMatches(refimgGray, key1, imgGray, key2, matches, None, flags=4,)
cv2.imwrite(r"C:AV GISmatches.jpg", imMatches)

return matches


When I look at a plot of the distance associated with the sorted matches I see many Hamming distance values of the same value:
Graph of match distances - x-axis is sorted match number, y-axis is Hamming distance. It looks like stair steps, with many matches sharing the same Hamming distance.



I am adding more filtering of matches to ensure they are geographically close, but I think I am forgoing many good matches just because they are "invisible" to the matcher.



Here is my question:
Can anyone explain how matches are decided when there is just one score to evaluate, and it is not unique? I tried the same thing with a single camera image (orders of magnitude smaller in number of pixels) and even then, the distance scores were not unique. Am I misunderstanding how these matches are found and used?



ADDED - here is a graph of best keypoint matches colored by geographic distances. graph of best keypoint matches colored by geographic distances







opencv orb






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 17:58







Andy Kellett

















asked Nov 21 '18 at 17:07









Andy KellettAndy Kellett

114




114













  • typically after matching, you should use some kind of higher algorithm to verify matches, like computing a homography with RANSAC, finding inliers and outliers, or to compute a fundamental matrix, detecting inliers and outliers. You could write your own matcher, which duplicates keypoints if there are many "best matches" for a single keypoint. But I'm not sure how exactly you mean those "same valued" distances. It is possible that there are 4 keypoints: A1, A2, B1, B2 in images 1 and 2 and that A1 has the same distance to A2 as B1 has to B2, but that the distance between A1 and B2 is bigger.

    – Micka
    Nov 22 '18 at 9:17











  • Thanks for your comment - When I look at my sorted matches, there can be ~100 matches with a Hamming distance of 14. How those 100 pairs are matched up - I am not sure. It looks kind of random to me, and so very few of those random matches seem to correspond to geographic matches. I'm going to think more carefully about your example at the comment. Thanks again.

    – Andy Kellett
    Nov 23 '18 at 17:13





















  • typically after matching, you should use some kind of higher algorithm to verify matches, like computing a homography with RANSAC, finding inliers and outliers, or to compute a fundamental matrix, detecting inliers and outliers. You could write your own matcher, which duplicates keypoints if there are many "best matches" for a single keypoint. But I'm not sure how exactly you mean those "same valued" distances. It is possible that there are 4 keypoints: A1, A2, B1, B2 in images 1 and 2 and that A1 has the same distance to A2 as B1 has to B2, but that the distance between A1 and B2 is bigger.

    – Micka
    Nov 22 '18 at 9:17











  • Thanks for your comment - When I look at my sorted matches, there can be ~100 matches with a Hamming distance of 14. How those 100 pairs are matched up - I am not sure. It looks kind of random to me, and so very few of those random matches seem to correspond to geographic matches. I'm going to think more carefully about your example at the comment. Thanks again.

    – Andy Kellett
    Nov 23 '18 at 17:13



















typically after matching, you should use some kind of higher algorithm to verify matches, like computing a homography with RANSAC, finding inliers and outliers, or to compute a fundamental matrix, detecting inliers and outliers. You could write your own matcher, which duplicates keypoints if there are many "best matches" for a single keypoint. But I'm not sure how exactly you mean those "same valued" distances. It is possible that there are 4 keypoints: A1, A2, B1, B2 in images 1 and 2 and that A1 has the same distance to A2 as B1 has to B2, but that the distance between A1 and B2 is bigger.

– Micka
Nov 22 '18 at 9:17





typically after matching, you should use some kind of higher algorithm to verify matches, like computing a homography with RANSAC, finding inliers and outliers, or to compute a fundamental matrix, detecting inliers and outliers. You could write your own matcher, which duplicates keypoints if there are many "best matches" for a single keypoint. But I'm not sure how exactly you mean those "same valued" distances. It is possible that there are 4 keypoints: A1, A2, B1, B2 in images 1 and 2 and that A1 has the same distance to A2 as B1 has to B2, but that the distance between A1 and B2 is bigger.

– Micka
Nov 22 '18 at 9:17













Thanks for your comment - When I look at my sorted matches, there can be ~100 matches with a Hamming distance of 14. How those 100 pairs are matched up - I am not sure. It looks kind of random to me, and so very few of those random matches seem to correspond to geographic matches. I'm going to think more carefully about your example at the comment. Thanks again.

– Andy Kellett
Nov 23 '18 at 17:13







Thanks for your comment - When I look at my sorted matches, there can be ~100 matches with a Hamming distance of 14. How those 100 pairs are matched up - I am not sure. It looks kind of random to me, and so very few of those random matches seem to correspond to geographic matches. I'm going to think more carefully about your example at the comment. Thanks again.

– Andy Kellett
Nov 23 '18 at 17:13














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417248%2forb-feature-match-and-degenerate-hamming-distance%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417248%2forb-feature-match-and-degenerate-hamming-distance%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin