-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drawing into a numpy view with a negative step in the channel dimension doesn't work #15895
Comments
|
There is lack of support in OpenCV for numpy on-the-fly reshaped arrays. OpenCV can't even copy data back if layout is not supported. Workaround: use return value. -cv.circle(image2, (50, 50), 10, (255, 255, 255), -1)
+image2 = cv.circle(image2, (50, 50), 10, (255, 255, 255), -1) image1 = 128 * np.ones((100, 100, 3), dtype='uint8')
cv.circle(image1, (50, 50), 10, (255, 255, 255), -1)
image2 = 128 * np.ones((100, 100, 3), dtype='uint8')
image2 = image2[:, :, ::-1]
cv.circle(image2, (50, 50), 10, (255, 255, 255), -1)
image2_ = cv.circle(image2, (50, 50), 10, (255, 255, 255), -1)
image3 = 128 * np.ones((100, 100, 3), dtype='uint8')
image3 = np.array(image3[:, :, ::-1])
cv.circle(image3, (50, 50), 10, (255, 255, 255), -1)
cv.imshow("1", image1)
cv.imshow("2", image2)
cv.imshow("2_", image2_)
cv.imshow("3", image3)
cv.waitKey() |
With patch from #15918 we can see this message of failed conversion:
Unfortunately, bindings wrapper didn't fail on these arguments and did moved forward to malformed |
System information (version)
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, emulatingcv.cvtColor
withCOLOR_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
The text was updated successfully, but these errors were encountered: