Ask Your Question
0

Mat to matOfByte conversion in java

asked Oct 6 '13

lobi gravatar image

updated Oct 6 '13

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();
Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Nov 13 '13

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.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Oct 6 '13

Seen: 2,098 times

Last updated: Nov 13 '13