1 | initial version |
Try it like this.
MatOfByte matOfByte = new MatOfByte();
Highgui.imencode(".png", mGray, matOfByte);
byte[] byteArray = matOfByte.toArray();
2 | No.2 Revision |
Try it like this.
MatOfByte matOfByte = new MatOfByte();
// encoding to png, so that your image does not lose information like with jpeg.
Highgui.imencode(".png", mGray, matOfByte);
matOfByte);
byte[] byteArray = matOfByte.toArray();