According to the Mobile Vision API documentation, the object Frame
has a method getBitmap()
, but it clearly stated that
getBitmap()
, , null, .
Bitmap, . - getGrayscaleImageData()
Frame
.
ByteBuffer
, Bitmap
.
-, YuvImage
byte getGrayscaleImageData()
. , YUV/YCbCr, NV21. , :
YuvImage yuvImage = new YuvImage(frame.getGrayscaleImageData().array(), ImageFormat.NV21, width, height, null);
width
height
getMedatada().getHeight()
/getMedatada().getWidth()
.
ByteArrayOutputStream
YuvImage
.
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
yuvImage.compressToJpeg(new Rect(0, 0, width, height), 100, byteArrayOutputStream);
, , , BitmapFactory
.
byte[] jpegArray = byteArrayOutputStream.toByteArray();
Bitmap bitmap = BitmapFactory.decodeByteArray(jpegArray, 0, jpegArray.length);
, , getBitmap()
, , .