Closed waicool20 closed 4 years ago
You need to invert the R and B channels. To do that easily, we can set the flipChannels
argument of Java2DFrameConverter.getBufferedImage()
and/or Java2DFrameConverter.getFrame()
to true
.
Duplicate of #1053
As to why it sometimes happens and sometimes doesn't, that's just how ImageIO and OpenCV work. You can refer to issues #181 and #1075 for additional information about this.
I'm trying to use Java2DFrameUtils class to convert my BufferedImage to Mat but it seems the R and B channel get mixed up in certain cases and I'm not able to assert what factor comes to play since some images show up just fine while others don't. I've checked the image properties through gimp and don't seem to see any problems between the cases.
I wrote this in kotlin hope you don't mind, the images here are random ones I found laying around as well.
Here's the original image:
And this is what shows up:
Another example:
This one works fine somehow
And of course