I am converting a NV21 image to a bitmap and then I display it. However, this is apparently very slow (I don't think I have much more than 1 fps). Do you have suggestions to improve that? This is my code:
byte nv21bytearray[] = frame.getImage();
Resolution size = frame.getSize();
Integer height = size.height;
Integer width = size.width;
YuvImage yuvImage = new YuvImage(nv21bytearray, ImageFormat.NV21, width, height, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
yuvImage.compressToJpeg(new Rect(0, 0, width, height), 100, os);
byte[] jpegByteArray = os.toByteArray();
bitmap = BitmapFactory.decodeByteArray(jpegByteArray, 0, jpegByteArray.length, options);
runOnUiThread(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
});
The phone I am using is a Motorola Moto E 4G (2nd generation of Moto E).