Wraps image data for on-device machine learning (ODML) usages.
MlImage
is designed to be an immutable image container, which could be shared
cross-platforms, among different Google ODML frameworks(TFLite Support, MLKit).
It is a common abstraction image that could help to chain different frameworks that adapts
MlImage
together.
To construct an MlImage
, use the provided builders:
MlImage
uses reference counting to maintain internal storage. When it is created the
reference count is 1. Developer can call close()
to reduce reference count to release
internal storage earlier, otherwise Java garbage collection will release the storage eventually.
To extract concrete image, first check MlImage.StorageType
and then use the provided
extractors:
MlImage
will support internal conversion(e.g. Bitmap -> ByteBuffer)
and multiple storages.
Nested Classes
@interface | MlImage.ImageFormat | Specifies the image format of an image. | |
class | MlImage.Internal | Advanced API access for MlImage . |
|
@interface | MlImage.StorageType | Specifies the image container type. |
Constants
int | IMAGE_FORMAT_ALPHA | |
int | IMAGE_FORMAT_JPEG | |
int | IMAGE_FORMAT_NV12 | |
int | IMAGE_FORMAT_NV21 | |
int | IMAGE_FORMAT_RGB | |
int | IMAGE_FORMAT_RGBA | |
int | IMAGE_FORMAT_UNKNOWN | |
int | IMAGE_FORMAT_YUV_420_888 | |
int | IMAGE_FORMAT_YV12 | |
int | IMAGE_FORMAT_YV21 | |
int | STORAGE_TYPE_BITMAP | |
int | STORAGE_TYPE_BYTEBUFFER | |
int | STORAGE_TYPE_IMAGE_PROXY | |
int | STORAGE_TYPE_MEDIA_IMAGE |
Public Methods
synchronized void |
close()
Removes a reference that was previously acquired or init.
|
List<ImageProperties> |
getContainedImageProperties()
Returns a list of supported image properties for this
MlImage . |
int |
getHeight()
Returns the height of the image.
|
MlImage.Internal |
getInternal()
Gets
MlImage.Internal object which contains internal APIs. |
int |
getRotation()
Returns the rotation value attached to the image.
|
int |
getWidth()
Returns the width of the image.
|
Inherited Methods
Constants
public static final int IMAGE_FORMAT_ALPHA
public static final int IMAGE_FORMAT_JPEG
public static final int IMAGE_FORMAT_NV12
public static final int IMAGE_FORMAT_NV21
public static final int IMAGE_FORMAT_RGB
public static final int IMAGE_FORMAT_RGBA
public static final int IMAGE_FORMAT_UNKNOWN
public static final int IMAGE_FORMAT_YUV_420_888
public static final int IMAGE_FORMAT_YV12
public static final int IMAGE_FORMAT_YV21
public static final int STORAGE_TYPE_BITMAP
public static final int STORAGE_TYPE_BYTEBUFFER
public static final int STORAGE_TYPE_IMAGE_PROXY
public static final int STORAGE_TYPE_MEDIA_IMAGE
Public Methods
public synchronized void close ()
Removes a reference that was previously acquired or init.
When MlImage
is created, it has 1 reference count.
When the reference count becomes 0, it will release the resource under the hood.
public List<ImageProperties> getContainedImageProperties ()
public int getHeight ()
Returns the height of the image.
public int getRotation ()
Returns the rotation value attached to the image. Rotation value will be 0, 90, 180, 270.
public int getWidth ()
Returns the width of the image.