<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.5.0</li>
<li>Operating System / Platform =&gt; Linux 64-bit</li>
<li>Compiler =&gt; / (python 3.8.6)</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I am calling the stereoCalibrate function in my python code, but always throws assertion errors:<br>
<code class="notranslate">result = cv2.stereoCalibrate(objectPoints, imagePointsA, imagePointsB, intrA, distA, intrB, distB, (848, 480))</code></p>
<p dir="auto">throws the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: OpenCV(4.5.0) /build/opencv/src/opencv-4.5.0/modules/calib3d/src/calibration.cpp:1088: error: (-215:Assertion failed) (count &gt;= 4) || (count == 3 &amp;&amp; useExtrinsicGuess) in function 'cvFindExtrinsicCameraParams2'"><pre class="notranslate"><code class="notranslate">error: OpenCV(4.5.0) /build/opencv/src/opencv-4.5.0/modules/calib3d/src/calibration.cpp:1088: error: (-215:Assertion failed) (count &gt;= 4) || (count == 3 &amp;&amp; useExtrinsicGuess) in function 'cvFindExtrinsicCameraParams2'
</code></pre></div>
<p dir="auto">if I try adding the USE_EXTRINSIC_GUESS flag, it still fails:<br>
<code class="notranslate">result = cv2.stereoCalibrate(objectPoints, imagePointsA, imagePointsB, intrA, distA, intrB, distB, (848, 480), flags=cv2.CALIB_FIX_INTRINSIC+cv2.CALIB_USE_EXTRINSIC_GUESS)</code></p>
<p dir="auto">throws the following error:<br>
<code class="notranslate">error: OpenCV(4.5.0) /build/opencv/src/opencv-4.5.0/modules/calib3d/src/calibration.cpp:3871: error: (-206:Bad flag (parameter or structure field)) stereoCalibrate does not support CALIB_USE_EXTRINSIC_GUESS. in function 'stereoCalibrate'</code></p>
<p dir="auto">What is the problem? According to documentation I should be able to use the extrinsic guess, right?<br>
Also, why am I getting an assertion error relating to number of object points (I guess), if I have 5704 object points in the array?<br>
<code class="notranslate">(count &gt;= 4) || (count == 3 &amp;&amp; useExtrinsicGuess) in function 'cvFindExtrinsicCameraParams2'</code></p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">I am passing the following arguments:<br>
<code class="notranslate">objectPoints</code> -&gt; python array, 5704 elements, where each looks like this:<br>
<code class="notranslate">array([[0.00375   , 0.09374999, 0.        ]], dtype=float32)</code> (numpy array of shape (1, 3))</p>
<p dir="auto">'imagePointsA'  and 'imagePointsB' -&gt; python array, 5704 elements, each element looks like this:<br>
<code class="notranslate">array([[64.84993 , 28.067667]], dtype=float32)</code> (numpy array of shape (1,2))</p>
<p dir="auto"><code class="notranslate">intrA</code> and <code class="notranslate">intrB</code> -&gt; numpy array, shape (3, 3). Looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="array([[615.22052002,   0.        , 431.19281006],
       [  0.        , 615.42181396, 243.2046051 ],
       [  0.        ,   0.        ,   1.        ]])
"><pre class="notranslate"><code class="notranslate">array([[615.22052002,   0.        , 431.19281006],
       [  0.        , 615.42181396, 243.2046051 ],
       [  0.        ,   0.        ,   1.        ]])

</code></pre></div>
<p dir="auto"><code class="notranslate">distA</code> and <code class="notranslate">distB</code> -&gt; numpy array, shape(5,), looks like this:<br>
<code class="notranslate"> array([0., 0., 0., 0., 0.], dtype=float32)</code></p>
<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>[ x] I checked the problem with documentation, FAQ, open issues,<br>
answers.opencv.org, Stack Overflow, etc and have not found solution

</li>
<li>[x ] I updated to latest OpenCV version and the issue is still there

</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> There is reproducer code and related data files: videos, images, onnx, etc

</li>
</ul>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 3.4.2</li>
<li>Operating System / Platform =&gt; Raspbian Stretch</li>
<li>Python =&gt; 3.5.3</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">When adding the CALIB_USE_EXTRINSIC_GUESS flag, stereoCalibrate will fail the CV_IS_MAT tests. When calling the same method without that flag, and with same arguments it completes without issue. Also calling stereoCalibrateExtended works both with and without the USE_EXTRINISC_GUESS flag.</p>
<p dir="auto">Not sure if this is related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="305658995" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/11085" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/11085/hovercard" href="https://github.com/opencv/opencv/issues/11085">#11085</a></p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="flags = cv2.CALIB_FIX_INTRINSIC
ret, mtx1, dist1, mtx2, dist2, R, T, E, F = cv2.stereoCalibrate(objpoints, imgpointsA, imgpointsB, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, grayA.shape[::-1], R=R, T=T, flags=flags, **kws)
flags += cv2.CALIB_USE_EXTRINSIC_GUESS
ret, mtx1, dist1, mtx2, dist2, R, T, E, F = cv2.stereoCalibrate(objpoints, imgpointsA, imgpointsB, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, grayA.shape[::-1], R=R, T=T, flags=flags, **kws)"><pre class="notranslate"><span class="pl-s1">flags</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-v">CALIB_FIX_INTRINSIC</span>
<span class="pl-s1">ret</span>, <span class="pl-s1">mtx1</span>, <span class="pl-s1">dist1</span>, <span class="pl-s1">mtx2</span>, <span class="pl-s1">dist2</span>, <span class="pl-v">R</span>, <span class="pl-v">T</span>, <span class="pl-v">E</span>, <span class="pl-v">F</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">stereoCalibrate</span>(<span class="pl-s1">objpoints</span>, <span class="pl-s1">imgpointsA</span>, <span class="pl-s1">imgpointsB</span>, <span class="pl-s1">cameraMatrix1</span>, <span class="pl-s1">distCoeffs1</span>, <span class="pl-s1">cameraMatrix2</span>, <span class="pl-s1">distCoeffs2</span>, <span class="pl-s1">grayA</span>.<span class="pl-s1">shape</span>[::<span class="pl-c1">-</span><span class="pl-c1">1</span>], <span class="pl-v">R</span><span class="pl-c1">=</span><span class="pl-v">R</span>, <span class="pl-v">T</span><span class="pl-c1">=</span><span class="pl-v">T</span>, <span class="pl-s1">flags</span><span class="pl-c1">=</span><span class="pl-s1">flags</span>, <span class="pl-c1">**</span><span class="pl-s1">kws</span>)
<span class="pl-s1">flags</span> <span class="pl-c1">+=</span> <span class="pl-s1">cv2</span>.<span class="pl-v">CALIB_USE_EXTRINSIC_GUESS</span>
<span class="pl-s1">ret</span>, <span class="pl-s1">mtx1</span>, <span class="pl-s1">dist1</span>, <span class="pl-s1">mtx2</span>, <span class="pl-s1">dist2</span>, <span class="pl-v">R</span>, <span class="pl-v">T</span>, <span class="pl-v">E</span>, <span class="pl-v">F</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">stereoCalibrate</span>(<span class="pl-s1">objpoints</span>, <span class="pl-s1">imgpointsA</span>, <span class="pl-s1">imgpointsB</span>, <span class="pl-s1">cameraMatrix1</span>, <span class="pl-s1">distCoeffs1</span>, <span class="pl-s1">cameraMatrix2</span>, <span class="pl-s1">distCoeffs2</span>, <span class="pl-s1">grayA</span>.<span class="pl-s1">shape</span>[::<span class="pl-c1">-</span><span class="pl-c1">1</span>], <span class="pl-v">R</span><span class="pl-c1">=</span><span class="pl-v">R</span>, <span class="pl-v">T</span><span class="pl-c1">=</span><span class="pl-v">T</span>, <span class="pl-s1">flags</span><span class="pl-c1">=</span><span class="pl-s1">flags</span>, <span class="pl-c1">**</span><span class="pl-s1">kws</span>)</pre></div>
<p dir="auto">Error output is:</p>
<blockquote>
<p dir="auto">cv2.error: OpenCV(3.4.2) /home/pi/opencv-3.4.2/modules/calib3d/src/calibration.cpp:1781: error: (-215:Assertion failed) (((_imagePoints1) != __null &amp;&amp; (((const CvMat*)(_imagePoints1))-&gt;type &amp; 0xFFFF0000) == 0x42420000 &amp;&amp; ((const CvMat*)(_imagePoints1))-&gt;cols &gt; 0 &amp;&amp; ((const CvMat*)(_imagePoints1))-&gt;rows &gt; 0) &amp;&amp; ((const CvMat*)(_imagePoints1))-&gt;data.ptr != __null) &amp;&amp; (((_imagePoints2) != __null &amp;&amp; (((const CvMat*)(_imagePoints2))-&gt;type &amp; 0xFFFF0000) == 0x42420000 &amp;&amp; ((const CvMat*)(_imagePoints2))-&gt;cols &gt; 0 &amp;&amp; ((const CvMat*)(_imagePoints2))-&gt;rows &gt; 0) &amp;&amp; ((const CvMat*)(_imagePoints2))-&gt;data.ptr != __null) &amp;&amp; (((_objectPoints) != __null &amp;&amp; (((const CvMat*)(_objectPoints))-&gt;type &amp; 0xFFFF0000) == 0x42420000 &amp;&amp; ((const CvMat*)(_objectPoints))-&gt;cols &gt; 0 &amp;&amp; ((const CvMat*)(_objectPoints))-&gt;rows &gt; 0) &amp;&amp; ((const CvMat*)(_objectPoints))-&gt;data.ptr != __null) &amp;&amp; (((_npoints) != __null &amp;&amp; (((const CvMat*)(_npoints))-&gt;type &amp; 0xFFFF0000) == 0x42420000 &amp;&amp; ((const CvMat*)(_npoints))-&gt;cols &gt; 0 &amp;&amp; ((const CvMat*)(_npoints))-&gt;rows &gt; 0) &amp;&amp; ((const CvMat*)(_npoints))-&gt;data.ptr != __null) &amp;&amp; (((matR) != __null &amp;&amp; (((const CvMat*)(matR))-&gt;type &amp; 0xFFFF0000) == 0x42420000 &amp;&amp; ((const CvMat*)(matR))-&gt;cols &gt; 0 &amp;&amp; ((const CvMat*)(matR))-&gt;rows &gt; 0) &amp;&amp; ((const CvMat*)(matR))-&gt;data.ptr != __null) &amp;&amp; (((matT) !=__null &amp;&amp; (((const CvMat*)(matT))-&gt;type &amp; 0xFFFF0000) == 0x42420000 &amp;&amp; ((const CvMat*)(matT))-&gt;cols &gt; 0 &amp;&amp; ((const CvMat*)(matT))-&gt;rows &gt; 0) &amp;&amp; ((const CvMat*)(matT))-&gt;data.ptr != __null) in function 'cvStereoCalibrateImpl'</p>
</blockquote>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# This one does not fail
flags = cv2.CALIB_FIX_INTRINSIC
flags += cv2.CALIB_USE_EXTRINSIC_GUESS
cv2.stereoCalibrateExtended(objpoints, imgpointsA, imgpointsB, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, grayA.shape[::-1], R, T, flags=flags)"><pre class="notranslate"><span class="pl-c"># This one does not fail</span>
<span class="pl-s1">flags</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-v">CALIB_FIX_INTRINSIC</span>
<span class="pl-s1">flags</span> <span class="pl-c1">+=</span> <span class="pl-s1">cv2</span>.<span class="pl-v">CALIB_USE_EXTRINSIC_GUESS</span>
<span class="pl-s1">cv2</span>.<span class="pl-en">stereoCalibrateExtended</span>(<span class="pl-s1">objpoints</span>, <span class="pl-s1">imgpointsA</span>, <span class="pl-s1">imgpointsB</span>, <span class="pl-s1">cameraMatrix1</span>, <span class="pl-s1">distCoeffs1</span>, <span class="pl-s1">cameraMatrix2</span>, <span class="pl-s1">distCoeffs2</span>, <span class="pl-s1">grayA</span>.<span class="pl-s1">shape</span>[::<span class="pl-c1">-</span><span class="pl-c1">1</span>], <span class="pl-v">R</span>, <span class="pl-v">T</span>, <span class="pl-s1">flags</span><span class="pl-c1">=</span><span class="pl-s1">flags</span>)</pre></div>