Skip to content

[firebase_ml_vision] Add rawBytes to the Barcode class (#1816) #1820

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

Closed
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ Tobias Löfstrand <[email protected]>
Stephen Beitzel <[email protected]>
Mark Veenstra <[email protected]>
Ben Hagen <[email protected]>
Marcus Bornman <[email protected]>
5 changes: 5 additions & 0 deletions packages/firebase_ml_vision/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.10.0

* **Breaking Change** Update Android firebase-ml-vision dependencies to latest.
* Add `rawBytes` property to `Barcode`.

## 0.9.3+9

* Fix for missing UserAgent.h compilation failures.
Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_ml_vision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
dependencies {
// ...

api 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
api 'com.google.firebase:firebase-ml-vision-image-label-model:19.0.0'
}
}
```
Expand All @@ -30,7 +30,7 @@ android {
dependencies {
// ...

api 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
api 'com.google.firebase:firebase-ml-vision-face-model:19.0.0'
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_ml_vision/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
disable 'InvalidPackage'
}
dependencies {
api 'com.google.firebase:firebase-ml-vision:20.0.0'
api 'com.google.firebase:firebase-ml-vision:24.0.1'
implementation 'com.google.firebase:firebase-common:16.1.0'
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void onSuccess(List<FirebaseVisionBarcode> firebaseVisionBarcodes) {
}
barcodeMap.put("points", points);

barcodeMap.put("rawBytes", barcode.getRawBytes());
barcodeMap.put("rawValue", barcode.getRawValue());
barcodeMap.put("displayValue", barcode.getDisplayValue());
barcodeMap.put("format", barcode.getFormat());
Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_ml_vision/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ android {
}

dependencies {
api 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
api 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
api 'com.google.firebase:firebase-ml-vision-image-label-model:19.0.0'
api 'com.google.firebase:firebase-ml-vision-face-model:19.0.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
1 change: 1 addition & 0 deletions packages/firebase_ml_vision/ios/Classes/BarcodeDetector.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (void)handleDetection:(FIRVisionImage *)image result:(FlutterResult)result {
[points addObject:@[ @(point.CGPointValue.x), @(point.CGPointValue.y) ]];
}
return @{
@"rawBytes" : barcode.rawData,
@"rawValue" : barcode.rawValue,
@"displayValue" : barcode.displayValue ? barcode.displayValue : [NSNull null],
@"left" : @(barcode.frame.origin.x),
Expand Down
6 changes: 6 additions & 0 deletions packages/firebase_ml_vision/lib/src/barcode_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class Barcode {
_data['height'],
)
: null,
rawBytes = _data['rawBytes'],
rawValue = _data['rawValue'],
displayValue = _data['displayValue'],
format = BarcodeFormat._(_data['format']),
Expand Down Expand Up @@ -293,6 +294,11 @@ class Barcode {
/// Could be null if the bounding rectangle can not be determined.
final Rect boundingBox;

/// Barcode bytes as they were encoded in the barcode.
///
/// Null if nothing found.
final Uint8List rawBytes;

/// Barcode value as it was encoded in the barcode.
///
/// Structured values are not parsed, for example: 'MEBKM:TITLE:Google;URL://www.google.com;;'.
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_ml_vision/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: firebase_ml_vision
description: Flutter plugin for Firebase machine learning vision services.
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_ml_vision
version: 0.9.3+9
version: 0.10.0

dependencies:
flutter:
Expand Down
14 changes: 14 additions & 0 deletions packages/firebase_ml_vision/test/firebase_ml_vision_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ void main() {
image = FirebaseVisionImage.fromFilePath('empty');
returnBarcodes = <dynamic>[
<dynamic, dynamic>{
'rawBytes': Uint8List.fromList(
[104, 101, 108, 108, 58, 114, 97, 119],
),
'rawValue': 'hello:raw',
'displayValue': 'hello:display',
'format': 0,
Expand Down Expand Up @@ -146,6 +149,10 @@ void main() {
// TODO(jackson): Use const Rect when available in minimum Flutter SDK
// ignore: prefer_const_constructors
expect(barcode.boundingBox, Rect.fromLTWH(1.0, 2.0, 3.0, 4.0));
expect(
barcode.rawBytes,
Uint8List.fromList([104, 101, 108, 108, 58, 114, 97, 119]),
);
expect(barcode.rawValue, 'hello:raw');
expect(barcode.displayValue, 'hello:display');
expect(barcode.cornerPoints, const <Offset>[
Expand Down Expand Up @@ -414,6 +421,9 @@ void main() {
test('detectInImage no bounding box', () async {
returnValue = <dynamic>[
<dynamic, dynamic>{
'rawBytes': Uint8List.fromList(
[112, 111, 116, 97, 116, 111, 58, 114, 97, 119],
),
'rawValue': 'potato:raw',
'displayValue': 'potato:display',
'valueType': 0,
Expand All @@ -429,6 +439,10 @@ void main() {

final Barcode barcode = barcodes[0];
expect(barcode.boundingBox, null);
expect(
barcode.rawBytes,
Uint8List.fromList([112, 111, 116, 97, 116, 111, 58, 114, 97, 119]),
);
expect(barcode.rawValue, 'potato:raw');
expect(barcode.displayValue, 'potato:display');
expect(barcode.cornerPoints, const <Offset>[
Expand Down