-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Drawing into a numpy view with a negative step in the channel dimension doesn't work #15895
Copy link
Copy link
Open
Description
System information (version)
- OpenCV => opencv-contrib-python-headless==4.1.1.26
- Operating System / Platform => OS X
Detailed description
I create three 3-channel images and draw a circle into them. In the second case I use the step trick A[:, :, ::-1] to flip the R and B channels in the image, emulating cv.cvtColor with COLOR_BGR2RGB. 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.
Expected is that cv.circle works in all three cases.
Steps to reproduce
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)Reactions are currently unavailable
