Class Image
- java.lang.Object
-
- com.microblink.documentverification.image.Image
-
- All Implemented Interfaces:
android.os.Parcelable
public class Image extends java.lang.Object implements android.os.ParcelableRepresents a image that is being processed.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedImage(android.os.Parcel in)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Imageclone()Creates and returns a copy of this image object.android.graphics.BitmapconvertToBitmap()Converts this image into Android Bitmap.intdescribeContents()voiddispose()Disposes native object containing image pixels.protected voidfinalize()java.nio.ByteBuffergetBuffer()Returns the native buffer that contains image pixels.intgetHeight()Returns the height of the image (corrected for the current orientation).ImageFormatgetImageFormat()Returns the format of the image.java.lang.StringgetImageName()Deprecated.Do not rely on this information anymore.OrientationgetImageOrientation()Returns the orientation of the image.ImageTypegetImageType()Returns the type of the image.intgetPixelStride()Returns the pixel stride for image buffer.intgetRawHeight()Returns the raw height of the image (uncorrected for the orientation)android.graphics.RectgetRawROI()Returns the region of interest in image in raw form (not corrected for orientation).intgetRawWidth()Returns the raw width of the image (uncorrected for the orientation)android.graphics.RectgetROI()Returns the region of interest in image corrected for current orientation of image.intgetRowStride()Returns the row stride for image buffer.intgetWidth()Returns the width of the image (corrected for the current orientation).booleanisDisposed()Returns true if image's internal buffers are disposed and cannot be used anymore.voidsetImageOrientation(Orientation orientation)Use this method to change Image's orientation.voidsetROI(android.graphics.Rect roi)Sets the region of interest in image.voidwriteToParcel(android.os.Parcel dest, int flags)
-
-
-
Field Detail
-
CREATOR
@NonNull public static final android.os.Parcelable.Creator<Image> CREATOR
-
-
Method Detail
-
dispose
public void dispose()
Disposes native object containing image pixels. After this method is called, Image object cannot be used anymore.
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
clone
@NonNull public Image clone()
Creates and returns a copy of this image object. This method makes a copy of image pixels. Use it if you want to use this image for later processing.- Overrides:
clonein classjava.lang.Object- Returns:
- a copy of this image object
-
getWidth
public int getWidth()
Returns the width of the image (corrected for the current orientation).- Returns:
- the width of the image (corrected for the current orientation).
-
getRawWidth
public int getRawWidth()
Returns the raw width of the image (uncorrected for the orientation)
-
getHeight
public int getHeight()
Returns the height of the image (corrected for the current orientation).- Returns:
- the height of the image (corrected for the current orientation).
-
getRawHeight
public int getRawHeight()
Returns the raw height of the image (uncorrected for the orientation)
-
getImageType
@NonNull public ImageType getImageType()
Returns the type of the image.- Returns:
- the type of the image.
-
getImageFormat
@NonNull public ImageFormat getImageFormat()
Returns the format of the image.- Returns:
- the format of the image.
-
getImageName
@NonNull @Deprecated public java.lang.String getImageName()
Deprecated.Do not rely on this information anymore. New API images will be nameless.Returns the name of the image.- Returns:
- the name of the image.
-
getBuffer
@NonNull public java.nio.ByteBuffer getBuffer()
Returns the native buffer that contains image pixels.- Returns:
- the native buffer that contains image pixels.
-
getPixelStride
public int getPixelStride()
Returns the pixel stride for image buffer. Pixel stride is byte difference between two consecutive pixels image row. It is guaranteed that pixel stride is at least 1.- Returns:
- the pixel stride for image buffer.
-
getRowStride
public int getRowStride()
Returns the row stride for image buffer. Row stride is byte difference between two consecutive rows in image.- Returns:
- the row stride for image plane
-
getROI
@NonNull public android.graphics.Rect getROI()
Returns the region of interest in image corrected for current orientation of image.
-
getRawROI
@NonNull public android.graphics.Rect getRawROI()
Returns the region of interest in image in raw form (not corrected for orientation). This is useful only for YUV_NV21 images that will contain the entire image in buffer and to obtain ROI-ed image, you should use YuvImage helper class (see:YuvImage)- Returns:
- the region of interest in image.
-
setROI
public void setROI(@NonNull android.graphics.Rect roi)Sets the region of interest in image. You can use this method to set the ROI of images that will be processed via RecognizerRunner. Coordinates of the ROI are applied in the current image's orientation - seegetImageOrientation().- Parameters:
roi- region of interest in image
-
getImageOrientation
@NonNull public Orientation getImageOrientation()
Returns the orientation of the image. Orientation is defined as orientation of the device when the image was taken. To explain the orientation further, let's assume that image contains a line of text. If orientation is Orientation.ORIENTATION_LANDSCAPE_RIGHT, the line of text would be horizontal from left to right (normal reading orientation). If orientation is Orientation.ORIENTATION_PORTRAIT, the line of text would be vertical from bottom to top. In order to read the text, you would need to rotate image by 90 degrees clockwise. If orientation is Orientation.ORIENTATION_PORTRAIT_UPSIDE, the line of text would be vertical from top to bottom. In order to read the text, you would need to rotate image by 90 degrees counterclockwise. If orientation is Orientation.ORIENTATION_LANDSCAPE_LEFT, the line of text would be horizontal from right to left (upside down). In order to read the text, you would need to rotate image by 180 degrees.- Returns:
- the orientation of the image
-
setImageOrientation
public void setImageOrientation(@NonNull Orientation orientation)Use this method to change Image's orientation. This can be useful for different interpretations of same image in different recognition contexts.- Parameters:
orientation-
-
isDisposed
public boolean isDisposed()
Returns true if image's internal buffers are disposed and cannot be used anymore.- Returns:
- true if image's internal buffers are disposed and cannot be used anymore.
-
convertToBitmap
@Nullable public android.graphics.Bitmap convertToBitmap()
Converts this image into Android Bitmap. This is a very slow process that involves copying and converting a lot of data. Returned bitmap has its own pixel buffer, so it may remain valid even after this image's buffers become invalid (i.e. after image gets disposed).- Returns:
- Image converted to Android Bitmap or null if conversion failed.
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(@NonNull android.os.Parcel dest, int flags)- Specified by:
writeToParcelin interfaceandroid.os.Parcelable
-
-