Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Bella, as explained in details here by Andrey Kamaev, you can use Highgui.imdecode function for conversion data in a JPEG format to Mat. So full code snippet looks like this:

Mat jpegData = new Mat(1, data.length, CvType.CV_8UC1);
jpegData.put(0, 0, data);
Mat bgrMat = Highgui.imdecode(jpegData, Highgui.IMREAD_COLOR);

For the second issue, you can save image in a number ways:

  • through FileOutputStream on device's storage;
  • use Highgui.imwrite to save a Mat;
  • just copy byte[] data into class member buffer.