<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.0.0-beta</li>
<li>Operating System / Platform =&gt; OSX 10.14.1 Beta (18B45d)</li>
<li>Compiler =&gt; Xcode (ver 10.0.0.10001145)</li>
<li>Python =&gt; 3.7.0</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">When retrieving frames in the latest version of OpenCV using the python bindings for OpenNI2, I found that the default value of the retrieve is used no matter what is passed into the binding <strong>unless the method is called with an additional dummy parameter</strong>.</p>
<p dir="auto">The method signature in the documentation is consistent:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="retval, image	= cv.VideoCapture.retrieve([, image[, flag]])"><pre class="notranslate"><code class="notranslate">retval, image	= cv.VideoCapture.retrieve([, image[, flag]])
</code></pre></div>
<p dir="auto">This would be sensible, however if you pass the image in, it <em>doesn't actually change the image as a side effect</em> which is what you would expect. Not only this, but there's no warning (or error) if you pass the flag in place of the image. Thus, while this may not explicitly be a bug, it's certainly a bit confusing, and it might need some clarification.</p>
<p dir="auto">In addition, this runs a bit contrary to the documentation which says:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[out]  | image |  the video frame is returned here. If no frames has been grabbed the image will be empty."><pre class="notranslate"><code class="notranslate">[out]  | image |  the video frame is returned here. If no frames has been grabbed the image will be empty.
</code></pre></div>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">Not Working:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="capture = cv2.VideoCapture(cv2.CAP_OPENNI2)
capture.grab()
ret_d, depth_map = capture.retrieve(cv2.CAP_OPENNI_DEPTH_MAP)
ret_f, frame = capture.retrieve(cv2.CAP_OPENNI_BGR_IMAGE)

print(cv2.CAP_OPENNI_BGR_IMAGE, cv2.CAP_OPENNI_DEPTH_MAP)
print(frame == depth_map)"><pre class="notranslate"><span class="pl-s1">capture</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-v">VideoCapture</span>(<span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI2</span>)
<span class="pl-s1">capture</span>.<span class="pl-en">grab</span>()
<span class="pl-s1">ret_d</span>, <span class="pl-s1">depth_map</span> <span class="pl-c1">=</span> <span class="pl-s1">capture</span>.<span class="pl-en">retrieve</span>(<span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_DEPTH_MAP</span>)
<span class="pl-s1">ret_f</span>, <span class="pl-s1">frame</span> <span class="pl-c1">=</span> <span class="pl-s1">capture</span>.<span class="pl-en">retrieve</span>(<span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_BGR_IMAGE</span>)

<span class="pl-en">print</span>(<span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_BGR_IMAGE</span>, <span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_DEPTH_MAP</span>)
<span class="pl-en">print</span>(<span class="pl-s1">frame</span> <span class="pl-c1">==</span> <span class="pl-s1">depth_map</span>)</pre></div>
<p dir="auto">The return value is:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt; 5, 0
&gt;&gt; True"><pre class="notranslate"><span class="pl-k">&gt;&gt;</span> 5, 0
<span class="pl-k">&gt;&gt;</span> True</pre></div>
<p dir="auto">Working:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="capture = cv2.VideoCapture(cv2.CAP_OPENNI2)
capture.grab()
ret_d, depth_map = capture.retrieve(None, cv2.CAP_OPENNI_DEPTH_MAP)
ret_f, frame = capture.retrieve(None, cv2.CAP_OPENNI_BGR_IMAGE)

print(cv2.CAP_OPENNI_BGR_IMAGE, cv2.CAP_OPENNI_DEPTH_MAP)
print(frame == depth_map)"><pre class="notranslate"><span class="pl-s1">capture</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-v">VideoCapture</span>(<span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI2</span>)
<span class="pl-s1">capture</span>.<span class="pl-en">grab</span>()
<span class="pl-s1">ret_d</span>, <span class="pl-s1">depth_map</span> <span class="pl-c1">=</span> <span class="pl-s1">capture</span>.<span class="pl-en">retrieve</span>(<span class="pl-c1">None</span>, <span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_DEPTH_MAP</span>)
<span class="pl-s1">ret_f</span>, <span class="pl-s1">frame</span> <span class="pl-c1">=</span> <span class="pl-s1">capture</span>.<span class="pl-en">retrieve</span>(<span class="pl-c1">None</span>, <span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_BGR_IMAGE</span>)

<span class="pl-en">print</span>(<span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_BGR_IMAGE</span>, <span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_DEPTH_MAP</span>)
<span class="pl-en">print</span>(<span class="pl-s1">frame</span> <span class="pl-c1">==</span> <span class="pl-s1">depth_map</span>)</pre></div>
<p dir="auto">The return value is:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt; 5, 0
&gt;&gt; False"><pre class="notranslate"><span class="pl-k">&gt;&gt;</span> 5, 0
<span class="pl-k">&gt;&gt;</span> False</pre></div>
<p dir="auto">Odd Behavior:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="capture = cv2.VideoCapture(cv2.CAP_OPENNI2)
capture.grab()
frame = None
ret_d, depth_map = capture.retrieve(None, cv2.CAP_OPENNI_DEPTH_MAP)
capture.retrieve(frame, cv2.CAP_OPENNI_BGR_IMAGE)

print(frame)"><pre class="notranslate"><span class="pl-s1">capture</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-v">VideoCapture</span>(<span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI2</span>)
<span class="pl-s1">capture</span>.<span class="pl-en">grab</span>()
<span class="pl-s1">frame</span> <span class="pl-c1">=</span> <span class="pl-c1">None</span>
<span class="pl-s1">ret_d</span>, <span class="pl-s1">depth_map</span> <span class="pl-c1">=</span> <span class="pl-s1">capture</span>.<span class="pl-en">retrieve</span>(<span class="pl-c1">None</span>, <span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_DEPTH_MAP</span>)
<span class="pl-s1">capture</span>.<span class="pl-en">retrieve</span>(<span class="pl-s1">frame</span>, <span class="pl-s1">cv2</span>.<span class="pl-v">CAP_OPENNI_BGR_IMAGE</span>)

<span class="pl-en">print</span>(<span class="pl-s1">frame</span>)</pre></div>
<p dir="auto">Output:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt; None"><pre class="notranslate"><span class="pl-k">&gt;&gt;</span> None</pre></div>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.5.1</li>
<li>Operating System / Platform =&gt; Ubuntu 20.04</li>
<li>Compiler =&gt; Pycharm</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">Unable to use sfm with opencv-python.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import cv2
help(cv2.sfm)"><pre class="notranslate"><code class="notranslate">import cv2
help(cv2.sfm)
</code></pre></div>
<p dir="auto">error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
AttributeError: module 'cv2.cv2' has no attribute 'sfm'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
AttributeError: module 'cv2.cv2' has no attribute 'sfm'
</code></pre></div>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import cv2
help(cv2.sfm)"><pre class="notranslate"><code class="notranslate">import cv2
help(cv2.sfm)
</code></pre></div>
<h5 dir="auto">Issue submission checklist</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I report the issue, it's not a question</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I checked the problem with documentation, FAQ, open issues,<br>
forum.opencv.org, Stack Overflow, etc and have not found solution</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I updated to latest OpenCV version and the issue is still there</li>
</ul>