Ask Your Question

prinsherbert's profile - activity

2020-10-04 16:24:14 -0600 received badge  Notable Question (source)
2020-01-27 06:18:49 -0600 received badge  Popular Question (source)
2018-05-31 09:57:50 -0600 marked best answer Why does knnMatch return a list of tuples instead of a list of DMatch?

This stitching example

https://docs.opencv.org/3.0-beta/doc/...

pipes the output of flann.knnMatch to cv2.drawMatchesKnn. Since the reference pages do not come close to properly documenting the output of knnMatch:

I decided to look at the implementation of drawMatchesKnn, but found something strange. In the python-code, the output of knnMatch is a list of lists of two DMatch objects:

matches[:3] == (
[[<DMatch 0x7ff57f981710>, <DMatch 0x7ff57f981130>],
 [<DMatch 0x7ff57f981330>, <DMatch 0x7ff57f981290>],
 [<DMatch 0x7ff57f981310>, <DMatch 0x7ff57f9816f0>]]
)

However drawMatchesKnn, to which matches is passed, these two line suggest it is a list of DMatches, instead of a list of lists of DMatches, since there is only one index [m] not two [m][n],

https://github.com/opencv/opencv/blob...

Moreover, this loop for i,(m,n) in enumerate(matches): in the first link also seems to ignore the second DMatch n in each sublist.

What is this second DMatch in each item of matches? Why is matches a list of tuples of DMatches, and not a list of 'DMatch`es?

It seems as if I can ignore the second DMatch, yet I don't feel comfortable blindly doing so.

2018-05-31 09:57:50 -0600 received badge  Scholar (source)
2018-05-31 09:57:46 -0600 commented answer Why does knnMatch return a list of tuples instead of a list of DMatch?

In the first link of the OP, they test whether the best test is at least 1.0/0.7 times better than the second best, and

2018-05-31 09:11:17 -0600 asked a question Why does knnMatch return a list of tuples instead of a list of DMatch?

Why does knnMatch return a list of tuples instead of a list of DMatch? This stitching example https://docs.opencv.org/3