Ask Your Question

Revision history [back]

The array "data" gives you the result of a single element of the Mat object. Thus, your initialization is wrong:

byte[] data = new byte[(int)mat.elemSize()];

However, if you're using a Mat with a single channel only you may also ignore the array:

System.out.println(mat.get(0, 0, new byte[(int) mat.elemSize()]));