Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting from Image to Mat - JavaFX

Hi,

I have a problem with converting data from Image (javafx.scene.image.Image) to Mat. Doing it the other way is quite straightforward:

public Image matToImage(Mat input) {
MatOfByte buf = new MatOfByte();    
Highgui.imencode(".png", input, buf);
return new Image(new ByteArrayInputStream(buf.toArray()));

}

Converting from Image to Mat - JavaFX

Hi,

I have a problem with converting data from Image (javafx.scene.image.Image) to Mat. Doing it the other way is quite straightforward:

public Image matToImage(Mat input) {
MatOfByte buf = new MatOfByte();    
Highgui.imencode(".png", input, buf);
return new Image(new ByteArrayInputStream(buf.toArray()));

}

click to hide/show revision 3
retagged

updated 2013-12-02 13:19:54 -0500

berak gravatar image

Converting from Image to Mat - JavaFX

Hi,

I have a problem converting data from Image (javafx.scene.image.Image) to Mat. Doing it the other way is quite straightforward:

public Image matToImage(Mat input) {
MatOfByte buf = new MatOfByte();    
Highgui.imencode(".png", input, buf);
return new Image(new ByteArrayInputStream(buf.toArray()));

}