How to get the positions of the matched points wit

2019-08-27 05:40发布

问题:

I tried matching my SIFT-Keypoints with BF-matcher. I used to do it like this tutorial https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html

But if i want to get the x,y-positions with print(good) it gives me only something like DMatch 000001DD9C4E0EB0

How can I convert this into positions?

回答1:

As you provided no code, I answer your question based on the code in the tutorial. Basically, keypoints are the points detected by the SIFT algorithm with the rotation, scale and x,y position, and descriptors are just the vectors of features used to match them. In the matches variable you have a set of matches between descriptors (DMatch). Keypoints are located in kp1 and kp2. To find two points (p1,p2) that are matched use the code like this:

for match in matches:
  p1 = kp1[match.queryIdx].pt
  p2 = kp2[match.trainIdx].pt