0

I am trying to use a custom made png image on OpenCV but it seems that the image is always messed up when read.

The original image: enter image description here

When I display it using OpenCV, it looks like: enter image description here

My code:

import cv2

img = cv2.imread("bottom_left.png", 0)

cv2.imshow("frame", img)

cv2.waitKey(0)

cv2.destroyAllWindows()
Che Su
  • 5
  • 3
  • 3
    Have a read in the documentation about that ugly `0` you have used as the last parameter to `imread()` instead of using the readable constants defined for you. Have a read about `imshow()` and its inability to display transparency. – Mark Setchell Jun 23 '20 at 21:02
  • Have a read here too... https://stackoverflow.com/a/58684791/2836621 – Mark Setchell Jun 23 '20 at 21:05
  • using 0 in imread doesn't necessarily equate to IMREAD_COLOR or LOAD_IMAGE_COLOR for whichever opencv version you are using. Use one of these listed here: https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga61d9b0126a3e57d9277ac48327799c80 or check the documentation for your appropriate opencv version – Warpstar22 Jun 23 '20 at 21:33

0 Answers0