Skip to content
Advertisement

cv2.imwrite doesn’t save result image but initial only

I have a code:

JavaScript

that generates grid like this one:

enter image description here

So cv2.imshow shows the grid but cv2.imwrite writes only initial black background not the grid for some reason. How to fix that?

Advertisement

Answer

You need to scale the color channels:

cv2.imwrite("background.jpg", background)

JavaScript

Alternatively you can create a “white” image with type uint8:

img = numpy.ones((255, 465, 3))

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement