Since OpenCV 3 the Highgui class doesn't exist anymore and the existing tutorials for OpenCV in Java which use Highgui don't apply anymore.
What is the proper way to convert a Mat to a JavaFX image and vice versa?
From my searches I found this for the Mat -> Image conversion which seems to work:
public static Image mat2Image(Mat frame) {
// create a temporary buffer
MatOfByte buffer = new MatOfByte();
// encode the frame in the buffer, according to the PNG format
Imgcodecs.imencode(".png", frame, buffer);
// build and return an Image created from the image encoded in the
// buffer
return new Image(new ByteArrayInputStream(buffer.toArray()));
}
I've also found solutions for Image to Mat conversion here and here. But they don't seem to be as convenient as Imgcodecs.imencode and I guess there would be an api for the conversion, but I can't find it.
How do you convert an Image to Mat with OpenCV 3?