将OpenCV Mat从和转换为JavaFX图像

将OpenCV Mat从和转换为JavaFX图像,opencv,javafx,Opencv,Javafx,由于OpenCV 3,Highgui类已经不存在,Java中使用Highgui的现有OpenCV教程也不再适用 将Mat转换为JavaFX图像或将其转换为JavaFX图像的正确方法是什么 从我的搜索中,我找到了Mat->图像转换的方法,这似乎很有效: public static Image mat2Image(Mat frame) { // create a temporary buffer MatOfByte buffer = new MatOfByte(); // e

由于OpenCV 3,Highgui类已经不存在,Java中使用Highgui的现有OpenCV教程也不再适用

将Mat转换为JavaFX图像或将其转换为JavaFX图像的正确方法是什么

从我的搜索中,我找到了Mat->图像转换的方法,这似乎很有效:

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()));
}
我还找到了图像到Mat转换的解决方案。但它们似乎不像Imgcodecs.imencode那么方便,我想可能会有一个用于转换的api,但我找不到它

如何使用OpenCV 3将图像转换为Mat