Package com.microblink.blinkid.image
Class ImageBuilder
java.lang.Object
com.microblink.blinkid.image.ImageBuilder
Utility class that can build
Image
object from various sources.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Image
buildImageFromJpegBytes
(byte[] bytes, int imageOrientation) static Image
buildImageFromNativeContext
(long nativeContext, boolean ownsNativeObject, Object keep) Builds image object from native context.static InputImage
buildInputImageFromByteBuffer
(ByteBuffer buffer, int width, int height, int rowStrideBytes, Orientation imageOrientation, Object keep) Builds the input image from a byte buffer which contains BGRA image data.static InputImage
buildInputImageFromCamera1NV21Frame
(byte[] imageBuffer, int imageWidth, int imageHeight, Orientation imageOrientation, Rectangle scanningRegion) static InputImage
buildInputImageFromCamera2Image
(android.media.Image image, Orientation imageOrientation, Rectangle scanningRegion) Builds input image object from Camera2 frame in YUV_420_888 format.static InputImage
static InputImage
buildInputImageFromNativeContext
(long nativeContext, boolean ownsNativeObject, Object keep) Builds image object from native context.
-
Constructor Details
-
ImageBuilder
public ImageBuilder()
-
-
Method Details
-
buildImageFromNativeContext
@NonNull public static Image buildImageFromNativeContext(long nativeContext, boolean ownsNativeObject, @Nullable Object keep) Builds image object from native context. This method is called from native code. Calling it directly from Java with invalid native context will crash the app.- Parameters:
nativeContext
- Native pointer containing native image object.ownsNativeObject
- Is native image owned by java object (i.e. should it be deleted on finalization)keep
- Object that must be kept alive while Image object is alive.- Returns:
Image
object for usage via RecognizerRunner'sRecognizerRunner
object.
-
buildImageFromJpegBytes
-
buildInputImageFromNativeContext
@NonNull public static InputImage buildInputImageFromNativeContext(long nativeContext, boolean ownsNativeObject, @Nullable Object keep) Builds image object from native context. This method is called from native code. Calling it directly from Java with invalid native context will crash the app.- Parameters:
nativeContext
- Native pointer containing native image object.ownsNativeObject
- Is native image owned by java object (i.e. should it be deleted on finalization)keep
- Object that must be kept alive while Image object is alive.- Returns:
Image
object for usage via RecognizerRunner'sRecognizerRunner
object.
-
buildInputImageFromCamera2Image
@NonNull public static InputImage buildInputImageFromCamera2Image(@NonNull android.media.Image image, @NonNull Orientation imageOrientation, @Nullable Rectangle scanningRegion) Builds input image object from Camera2 frame in YUV_420_888 format.- Parameters:
image
-Image
object that contains image from which MicroBlinkImage
will be built. You must ensure that this object is not closed while returnedImage
is in use. Doing so will lead to undefined behaviour.imageOrientation
- Orientation of the device at the timeImage
was created. Cannot be null norOrientation.ORIENTATION_UNKNOWN
.scanningRegion
- Region of image that will be used for recognition. If null, entire image will be used.- Returns:
Image
object for usage via RecognizerRunner'sRecognizerRunner
object.
-
buildInputImageFromCamera1NV21Frame
@NonNull public static InputImage buildInputImageFromCamera1NV21Frame(@NonNull byte[] imageBuffer, int imageWidth, int imageHeight, @NonNull Orientation imageOrientation, @Nullable Rectangle scanningRegion) -
buildInputImageFromImage
-
buildInputImageFromByteBuffer
@NonNull public static InputImage buildInputImageFromByteBuffer(@NonNull ByteBuffer buffer, int width, int height, int rowStrideBytes, @NonNull Orientation imageOrientation, @Nullable Object keep) Builds the input image from a byte buffer which contains BGRA image data.- Parameters:
buffer
- Byte buffer containing BGRA image data.width
- Width of the image.height
- Height of the image.rowStrideBytes
- Row stride of the image. This is the number of bytes that each row of the image occupies in the buffer.imageOrientation
- Image orientationkeep
- Object that must be kept alive while Image object is alive. Can be null if no object needs to be kept alive.- Returns:
InputImage
object for usage via RecognizerRunner'sRecognizerRunner
object.
-