-1

Apparently it was possible in OpenCV 2.4 with Java bindings to convert a Mat into a BufferedImage:

val greyMat = new Mat()
opencv_imgproc.cvtColor(mat, greyMat, opencv_imgproc.CV_BGR2GRAY, 1)
ImageIO.write(greyMat.getBufferedImage, "jpg", new File("output_grey.jpg"))

I tried updating a project that used this code (and it worked, I checked) to use OpenCV 3.1, and it seems this method has gone.

Why is this method getBufferedImage removed from API, and how do I get back to it?

0__
  • 66,707
  • 21
  • 171
  • 266

1 Answers1

0

It seems there is a separate converter class now: Java2DFrameConverter:

import org.bytedeco.javacv.Java2DFrameConverter

val greyMat = new Mat()
val conv = new Java2DFrameConverter
opencv_imgproc.cvtColor(mat, greyMat, opencv_imgproc.CV_BGR2GRAY, 1)
ImageIO.write(conv.getBufferedImage(greyMat), "jpg", new File("output_grey.jpg"))
0__
  • 66,707
  • 21
  • 171
  • 266