Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support more image formats on Android #634

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/google_mlkit_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.7.2

* Widened image format support for Android
* Improve documentation for image formats

## 0.7.1

* Update README.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static InputImage getInputImageFromData(Map<String, Object> imageData,
(int) (double) metaData.get("width"),
(int) (double) metaData.get("height"),
(int) metaData.get("rotation"),
InputImage.IMAGE_FORMAT_NV21);
(int) metaData.get("image_format"));
return inputImage;
} else {
result.error("InputImageConverterError", "Invalid Input Image", null);
Expand Down
19 changes: 18 additions & 1 deletion packages/google_mlkit_commons/lib/src/input_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ class InputImageMetadata {

/// Format of the input image.
///
/// Not used on Android.
/// Android supports
/// - [InputImageFormat.nv21]
/// - [InputImageFormat.yuv_420_888]
/// - [InputImageFormat.yv12]
/// as described in [here](https://developers.google.com/android/reference/com/google/mlkit/vision/common/InputImage.ImageFormat).
///
/// iOS supports
/// - [InputImageFormat.yuv420]
/// - [InputImageFormat.bgra8888]
final InputImageFormat format;

/// The row stride for color plane, in bytes.
Expand Down Expand Up @@ -122,10 +130,19 @@ extension InputImageRotationValue on InputImageRotation {

/// To indicate the format of image while creating input image from bytes
enum InputImageFormat {
/// Android only: https://developers.google.com/android/reference/com/google/mlkit/vision/common/InputImage#IMAGE_FORMAT_NV21
nv21,

/// Android only: https://developers.google.com/android/reference/com/google/mlkit/vision/common/InputImage#public-static-final-int-image_format_yv12
yv12,

/// Android only: https://developers.google.com/android/reference/com/google/mlkit/vision/common/InputImage#public-static-final-int-image_format_yuv_420_888
yuv_420_888,

/// iOS only: https://developer.apple.com/documentation/corevideo/kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
yuv420,

/// iOS only: https://developer.apple.com/documentation/corevideo/kcvpixelformattype_32bgra
bgra8888,
}

Expand Down
2 changes: 1 addition & 1 deletion packages/google_mlkit_commons/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: google_mlkit_commons
description: A Flutter plugin with commons files to implement google's standalone ml kit made for mobile platform.
version: 0.7.1
version: 0.7.2
homepage: https://github.com/flutter-ml/google_ml_kit_flutter

environment:
Expand Down