FirebaseVisionImage

public class FirebaseVisionImage extends Object

Represents an image object that can be used for both on-device and cloud API detectors.

Public Method Summary

static FirebaseVisionImage
fromBitmap(Bitmap bitmap)
Creates a FirebaseVisionImage from a Bitmap, where the object in the image should be already up-right and no rotation is needed.
static FirebaseVisionImage
fromByteArray(byte[] byteArray, FirebaseVisionImageMetadata metadata)
Creates a FirebaseVisionImage from a byte array, e.g.
static FirebaseVisionImage
static FirebaseVisionImage
fromFilePath(Context context, Uri imageUri)
Creates a FirebaseVisionImage from a local image file Uri.
static FirebaseVisionImage
fromMediaImage(Image image, int rotation)
Creates a FirebaseVisionImage from a Image object, e.g.

Inherited Method Summary

Public Methods

public static FirebaseVisionImage fromBitmap (Bitmap bitmap)

Creates a FirebaseVisionImage from a Bitmap, where the object in the image should be already up-right and no rotation is needed.

public static FirebaseVisionImage fromByteArray (byte[] byteArray, FirebaseVisionImageMetadata metadata)

Creates a FirebaseVisionImage from a byte array, e.g. what you get from Camera callback.

public static FirebaseVisionImage fromByteBuffer (ByteBuffer byteBuffer, FirebaseVisionImageMetadata metadata)

Creates a FirebaseVisionImage from a ByteBuffer.

We assume the entire buffer from position zero to its limit is all image data.

public static FirebaseVisionImage fromFilePath (Context context, Uri imageUri)

Creates a FirebaseVisionImage from a local image file Uri.

Throws
IOException if the image could not be retrieved from the specified imageUri. This could happen even if the Uri came from content chooser, e.g. some users might have content providers for remote resources.

public static FirebaseVisionImage fromMediaImage (Image image, int rotation)

Creates a FirebaseVisionImage from a Image object, e.g. what you obtained from android.hardware.camera2 API.

Note that we only support JPEG / YUV_420_888 formats at this moment. If you are using cloud vision detectors, JPEG format is recommended; if you are using on-device detectors, YUV_420_888 will be more efficient.

After you get back a FirebaseVisionImage, it's safe to close the input Image.

Parameters
image
rotation The camera rotation, e.g. ROTATION_90 for back camera landscape mode. See also FirebaseVisionImageMetadata.Rotation.

Send feedback about...

Need help? Visit our support page.