In my Android app I'm streaming images (all of same size) over the network to the Android device. Usually the stream is then decoded into a Bitmap like this:
Bitmap bmp = BitmapFactory.decodeByteArray(buffer, 0,
buffer.length);
But this allocated and de-allocates memory all the time. Therefore I would prefer creating an OpenCV Mat and put the received buffer (byte[]) into that. But I just get a white-noise image because my image format seems wrong. Maybe you can help me? On the senders side (.NET C#) it's a PNG with 24bppRgb. On the receivers side (Android) I'm currently initializing the Mat like this:
Mat mat = new Mat(new Size(width, height), CvType.CV_8U); mat.put(0, 0, buffer);