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

<ul dir="auto">
<li>OpenCV =&gt; 4.2 python</li>
<li>Operating System / Platform =&gt; 20.04.1-Ubuntu x86_64</li>
<li>Compiler =&gt; binary provided by apt package</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">It seems that cv2.cornerSubPix function does only accept the corners output from cv2.findChessboardCorners directly.<br>
Reversing this list in python leads to an error:<br>
<code class="notranslate">corners = corners[::-1,:,:]</code></p>
<blockquote>
<p dir="auto">TypeError: Expected Ptrcv::UMat for argument 'corners'</p>
</blockquote>
<p dir="auto">Storing the inverted corners inplace does work:<br>
<code class="notranslate">corners[:] = corners[::-1,:,:]</code></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="import cv2
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
img = cv2.imread(&quot;test.png&quot;)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

ret, corners = cv2.findChessboardCorners(gray, (4,6), None)
if ret == True:
    print(corners.__class__)                                               # &lt;class 'numpy.ndarray'&gt;
    corners2 = cv2.cornerSubPix(gray, corners, (11,11), (-1,-1), criteria) # works

    corners[:] = corners[::-1,:,:]                                         # reverse inplace
    print(corners.__class__)                                               # &lt;class 'numpy.ndarray'&gt;
    corners2 = cv2.cornerSubPix(gray, corners, (11,11), (-1,-1), criteria) # also works


    corners = corners[::-1,:,:]                                            # reverse into new object
    print(corners.__class__)                                               # &lt;class 'numpy.ndarray'&gt;
    corners2 = cv2.cornerSubPix(gray, corners, (11,11), (-1,-1), criteria) # Error: TypeError: Expected Ptr&lt;cv::UMat&gt; for argument 'corners'"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">cv2</span>
<span class="pl-s1">criteria</span> <span class="pl-c1">=</span> (<span class="pl-s1">cv2</span>.<span class="pl-v">TERM_CRITERIA_EPS</span> <span class="pl-c1">+</span> <span class="pl-s1">cv2</span>.<span class="pl-v">TERM_CRITERIA_MAX_ITER</span>, <span class="pl-c1">30</span>, <span class="pl-c1">0.001</span>)
<span class="pl-s1">img</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">imread</span>(<span class="pl-s">"test.png"</span>)
<span class="pl-s1">gray</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">cvtColor</span>(<span class="pl-s1">img</span>, <span class="pl-s1">cv2</span>.<span class="pl-v">COLOR_BGR2GRAY</span>)

<span class="pl-s1">ret</span>, <span class="pl-s1">corners</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">findChessboardCorners</span>(<span class="pl-s1">gray</span>, (<span class="pl-c1">4</span>,<span class="pl-c1">6</span>), <span class="pl-c1">None</span>)
<span class="pl-k">if</span> <span class="pl-s1">ret</span> <span class="pl-c1">==</span> <span class="pl-c1">True</span>:
    <span class="pl-en">print</span>(<span class="pl-s1">corners</span>.<span class="pl-s1">__class__</span>)                                               <span class="pl-c"># &lt;class 'numpy.ndarray'&gt;</span>
    <span class="pl-s1">corners2</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">cornerSubPix</span>(<span class="pl-s1">gray</span>, <span class="pl-s1">corners</span>, (<span class="pl-c1">11</span>,<span class="pl-c1">11</span>), (<span class="pl-c1">-</span><span class="pl-c1">1</span>,<span class="pl-c1">-</span><span class="pl-c1">1</span>), <span class="pl-s1">criteria</span>) <span class="pl-c"># works</span>

    <span class="pl-s1">corners</span>[:] <span class="pl-c1">=</span> <span class="pl-s1">corners</span>[::<span class="pl-c1">-</span><span class="pl-c1">1</span>,:,:]                                         <span class="pl-c"># reverse inplace</span>
    <span class="pl-en">print</span>(<span class="pl-s1">corners</span>.<span class="pl-s1">__class__</span>)                                               <span class="pl-c"># &lt;class 'numpy.ndarray'&gt;</span>
    <span class="pl-s1">corners2</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">cornerSubPix</span>(<span class="pl-s1">gray</span>, <span class="pl-s1">corners</span>, (<span class="pl-c1">11</span>,<span class="pl-c1">11</span>), (<span class="pl-c1">-</span><span class="pl-c1">1</span>,<span class="pl-c1">-</span><span class="pl-c1">1</span>), <span class="pl-s1">criteria</span>) <span class="pl-c"># also works</span>


    <span class="pl-s1">corners</span> <span class="pl-c1">=</span> <span class="pl-s1">corners</span>[::<span class="pl-c1">-</span><span class="pl-c1">1</span>,:,:]                                            <span class="pl-c"># reverse into new object</span>
    <span class="pl-en">print</span>(<span class="pl-s1">corners</span>.<span class="pl-s1">__class__</span>)                                               <span class="pl-c"># &lt;class 'numpy.ndarray'&gt;</span>
    <span class="pl-s1">corners2</span> <span class="pl-c1">=</span> <span class="pl-s1">cv2</span>.<span class="pl-en">cornerSubPix</span>(<span class="pl-s1">gray</span>, <span class="pl-s1">corners</span>, (<span class="pl-c1">11</span>,<span class="pl-c1">11</span>), (<span class="pl-c1">-</span><span class="pl-c1">1</span>,<span class="pl-c1">-</span><span class="pl-c1">1</span>), <span class="pl-s1">criteria</span>) <span class="pl-c"># Error: TypeError: Expected Ptr&lt;cv::UMat&gt; for argument 'corners'</span></pre></div>
<p dir="auto"><a href="https://github.com/opencv/opencv/files/6343067/test.png.tar.gz">test.png.tar.gz</a></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 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"> 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" checked=""> 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; opencv-contrib-python-headless==4.1.1.26</li>
<li>Operating System / Platform =&gt; OS X</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I create three 3-channel images and draw a circle into them. In the second case I use the step trick <code class="notranslate">A[:, :, ::-1]</code> to flip the R and B channels in the image, emulating <code class="notranslate">cv.cvtColor</code> with <code class="notranslate">COLOR_BGR2RGB</code>. I then try to draw into that array. The result, as seen in the screenshot, is that nothing gets drawn. In the third case I explicitly make a copy of the channel-flipped array (which is actually a view) before drawing, and it works.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/730130/68665520-7a88fd80-0542-11ea-8cab-531c56921bc8.png"><img src="https://user-images.githubusercontent.com/730130/68665520-7a88fd80-0542-11ea-8cab-531c56921bc8.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Expected is that cv.circle works in all three cases.</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="import cv2 as cv

image1 = np.zeros((100, 100, 3), dtype='uint8')
cv.circle(image1, (50, 50), 10, (255, 255, 255), -1)

image2 = np.zeros((100, 100, 3), dtype='uint8')
image2 = image2[:, :, ::-1]
cv.circle(image2, (50, 50), 10, (255, 255, 255), -1)

image3 = np.zeros((100, 100, 3), dtype='uint8')
image3 = np.array(image3[:, :, ::-1])
cv.circle(image3, (50, 50), 10, (255, 255, 255), -1)

imshow(image1, image2, image3)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">cv2</span> <span class="pl-k">as</span> <span class="pl-s1">cv</span>

<span class="pl-s1">image1</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">zeros</span>((<span class="pl-c1">100</span>, <span class="pl-c1">100</span>, <span class="pl-c1">3</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'uint8'</span>)
<span class="pl-s1">cv</span>.<span class="pl-en">circle</span>(<span class="pl-s1">image1</span>, (<span class="pl-c1">50</span>, <span class="pl-c1">50</span>), <span class="pl-c1">10</span>, (<span class="pl-c1">255</span>, <span class="pl-c1">255</span>, <span class="pl-c1">255</span>), <span class="pl-c1">-</span><span class="pl-c1">1</span>)

<span class="pl-s1">image2</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">zeros</span>((<span class="pl-c1">100</span>, <span class="pl-c1">100</span>, <span class="pl-c1">3</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'uint8'</span>)
<span class="pl-s1">image2</span> <span class="pl-c1">=</span> <span class="pl-s1">image2</span>[:, :, ::<span class="pl-c1">-</span><span class="pl-c1">1</span>]
<span class="pl-s1">cv</span>.<span class="pl-en">circle</span>(<span class="pl-s1">image2</span>, (<span class="pl-c1">50</span>, <span class="pl-c1">50</span>), <span class="pl-c1">10</span>, (<span class="pl-c1">255</span>, <span class="pl-c1">255</span>, <span class="pl-c1">255</span>), <span class="pl-c1">-</span><span class="pl-c1">1</span>)

<span class="pl-s1">image3</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">zeros</span>((<span class="pl-c1">100</span>, <span class="pl-c1">100</span>, <span class="pl-c1">3</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'uint8'</span>)
<span class="pl-s1">image3</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-s1">image3</span>[:, :, ::<span class="pl-c1">-</span><span class="pl-c1">1</span>])
<span class="pl-s1">cv</span>.<span class="pl-en">circle</span>(<span class="pl-s1">image3</span>, (<span class="pl-c1">50</span>, <span class="pl-c1">50</span>), <span class="pl-c1">10</span>, (<span class="pl-c1">255</span>, <span class="pl-c1">255</span>, <span class="pl-c1">255</span>), <span class="pl-c1">-</span><span class="pl-c1">1</span>)

<span class="pl-en">imshow</span>(<span class="pl-s1">image1</span>, <span class="pl-s1">image2</span>, <span class="pl-s1">image3</span>)</pre></div>