Ask Your Question
0

Mat to matOfByte conversion in java

asked 2013-10-05 19:49:23 -0500

lobi gravatar image

updated 2013-10-06 01:55:06 -0500

berak gravatar image

Can someone explain what this code is doing.I mean how big is byteArray If I have Mat dimension (h= 300, w = 400)?

    MatOfByte matOfByte = new MatOfByte();

    Highgui.imencode(".jpg", image_tmp, matOfByte); 

    byte[] byteArray = matOfByte.toArray();
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2013-11-13 13:03:56 -0500

This code compresses an image (Mat) to jpg, and returns that as a byte array.

The byteArray will be 300 x 400 x number of channels.

Or you can just use byteArray.length in order to find out.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2013-10-05 19:49:23 -0500

Seen: 1,356 times

Last updated: Nov 13 '13