New Mobile Vision API Detector Frame Gets Bitmap

I know that the Question was asked earlier: - Mobile Vision API - combine a new detector object to continue processing frames

I get the frame, but when I call frame.getBitmap (), it returns a null object. I want to use this bitmap in the https://github.com/tzutalin/dlib-android-app  (Android dlib Library) FaceDet function.

+6
source share
1 answer

According to the Mobile Vision API documentation, the object Framehas 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(), , .

0

Source: https://habr.com/ru/post/1016806/


All Articles