将OpenCV Mat转换为JavaFX映像

时间:2015-09-13 09:17:26

标签: opencv javafx

从OpenCV 3开始,Highgui类不再存在,而现有的使用Highgui的Java OpenCV教程不再适用。

将Mat转换为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()));
}

我还找到了Image to Mat转换herehere的解决方案。但是它们似乎不像Imgcodecs.imencode那么方便,我想转换会有一个api,但我找不到它。

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

0 个答案:

没有答案