OpenCV, DMatch objects in Python and Julia don't match
<p>I'm trying to implement a feature matching method using OpenCV, but the translation from a Python version to Julia does not match up:</p>

<p>The methods are exactly the same and use the same images for processing. (<code>[:method]</code> is just standard convention for accessing a specific type of method in Julia, so don't be fooled! Also, Julia indexing starts at 1, not 0, so these two sets of print statements <em>should</em> yield the same result, but they don't.)</p>

<p><strong>Julia version:</strong></p>

<pre><code>query = cv2.imread("images/q1.jpg",0)
train = cv2.imread("images/q2.jpg",0) 

orb = cv2.ORB_create()

kp1 = orb[:detect](query)
kp1, des1 = orb[:compute](query, kp1)

kp2 = orb[:detect](train)
kp2, des2 = orb[:compute](train, kp2)

bf = cv2.BFMatcher()
matches = bf[:knnMatch](des1, des2, k=2)

print(matches[1])
print(matches[1][:distance])
</code></pre>

<p>prints the below. Only one DMatch object is stored in <code>matches</code>.</p>

<pre><code>PyObject &lt;DMatch 0x7fac68b2be50&gt;
305.0639343261719
</code></pre>

<p><strong>Python version:</strong></p>

<pre><code>query = cv2.imread('images/q1.jpg',0)       
train = cv2.imread('images/q2.jpg',0)

orb = cv2.ORB_create()

kp1 = orb.detect(query)
kp1, des1 = orb.compute(query, kp1)

kp2 = orb.detect(train)
kp2, des2 = orb.compute(train, kp2)

bf = cv2.BFMatcher()
matches = bf.knnMatch(des1, des2, k=2)

print(matches[0])
print(matches[0][0].distance)
</code></pre>

<p>prints the below. Two DMatch objects are stored in <code>matches</code></p>

<pre><code>[&lt;DMatch 0x7f0266a47a70&gt;, &lt;DMatch 0x7f0266a47c50&gt;]
305.0639343261719
</code></pre>

<p>My question is, why is only one DMatch object stored in the <code>matches</code> that I created with Julia, but two are stored in the one I created with Python, [<strong>NOTE</strong>: I need both DMatch objects to successfully implement feature matching, so the Python one is correct!] and how can I fix the problem? </p>

<p>Any help is much appreciated.</p>

<p>EDIT:
writing <code>print(matches)</code> for both examples gives the following:  </p>

<p>In Julia:</p>

<pre><code>Any[PyObject &lt;DMatch 0x7ff58c290f90&gt; PyObject &lt;DMatch 0x7ff58c290fb0&gt;
    PyObject &lt;DMatch 0x7ff58c290fd0&gt; PyObject &lt;DMatch 0x7ff58c2bc030&gt;
…
    PyObject &lt;DMatch 0x7ff58c24be10&gt; PyObject &lt;DMatch 0x7ff58c24be30&gt;
    PyObject &lt;DMatch 0x7ff58c24be50&gt; PyObject &lt;DMatch 0x7ff58c24be70&gt;]
</code></pre>

<p>In Python:             </p>

<p><code>[[&lt;DMatch 0x7fcda37c5730&gt;, &lt;DMatch 0x7fcda37c5830&gt;], [&lt;DMatch 0x7fcda37c5650&gt;, &lt;DMatch 0x7fcda37c5610&gt;],... [&lt;DMatch 0x7fcda375f5d0&gt;, &lt;DMatch 0x7fcda375f5f0&gt;], [&lt;DMatch 0x7fcda375f610&gt;, &lt;DMatch 0x7fcda375f630&gt;]]</code></p>