Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Code cleanup and added metadata for ML Vision #631

Merged
merged 40 commits into from
Jun 28, 2018

Conversation

bparrishMines
Copy link
Contributor

No description provided.

@bparrishMines bparrishMines changed the title Code cleanup and added metadat for ML Vision Code cleanup and added metadata for ML Vision Jun 22, 2018
@bparrishMines
Copy link
Contributor Author

This PR is also missing a rebase. I'm working on rebasing it correctly. The HEAD for this branch is 9c2af92.

Copy link
Contributor

@mravn-google mravn-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

FlutterFire.md Outdated
@@ -26,6 +26,7 @@ The plugins are still under development, and some APIs might not be available ye
| [firebase_performance][performance_pub] | ![pub package][performance_badge] | [Firebase Performance Monitoring][performance_product] | [`packages/firebase_performance`][performance_code] |
| [firebase_remote_config][remote_config_pub] | ![pub package][remote_config_badge] | [Firebase Remote Config][remote_config_product] | [`packages/firebase_remote_config`][remote_config_code] |
| [cloud_functions][functions_pub] | ![pub package][functions_badge] | [Cloud Functions][functions_product] | [`packages/cloud_functions`][functions_code] |
| [firebase_ml_vision][ml_vision_pub] | ![pub package][ml_vision_badge] | [Firebase ML Kit][ml_vision_product] | [`packages/firebase_ml_vision`][ml_vision_code] |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list is getting long. Perhaps alphabetize it?

README.md Outdated
@@ -70,5 +70,6 @@ These are the available plugins in this repository.
| [firebase_remote_config](./packages/firebase_remote_config/) | [![pub package](https://img.shields.io/pub/v/firebase_remote_config.svg)](https://pub.dartlang.org/packages/firebase_remote_config) |
| [firebase_dynamic_links](./packages/firebase_dynamic_links/) | [![pub package](https://img.shields.io/pub/v/firebase_dynamic_links.svg)](https://pub.dartlang.org/packages/firebase_dynamic_links) |
| [cloud_functions](./packages/cloud_functions/) | [![pub package](https://img.shields.io/pub/v/cloud_functions.svg)](https://pub.dartlang.org/packages/cloud_functions) |
| [firebase_ml_vision](./packages/firebase_ml_vision/) | [![pub package](https://img.shields.io/pub/v/firebase_ml_vision.svg)](https://pub.dartlang.org/packages/firebase_ml_vision) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


## Usage

To use this plugin, add `firebase_ml_vision` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). You must also configure firebase for each platform project: Android and iOS (see the example folder or https://codelabs.developers.google.com/codelabs/flutter-firebase/#4 for step by step details).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"configure firebase" => "configure Firebase"?


To use the on-device text recognition model, run the text detector as described below:

1. Create a FirebaseVisionImage object from your image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FirebaseVisionImage should be code font for consistency.

final String text = block.text;

for (TextLine line in block.lines) {
// ....
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An ellipsis is usually three dots: // ...

try {
textDetector.close();
} catch (IOException exception) {
result.error("textDetectorError", exception.getLocalizedMessage(), null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get to this code, we'll be invoking both result.error and result.success.

/// Due to the possible perspective distortions, this is not necessarily a
/// rectangle. Parts of the region could be outside of the image.
///
/// Could be empty even if text is found.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea what that means or when that happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The android implementation has the @Nullable annotation for boundingBox() and cornerPoints(). I haven't found anywhere that specifies why or had it actually return null for any of the test images. However, I added code and a comment to handle it just in case it does because I didn't want it to accidentally crash an app. Also, I get warnings from android studio to handle a null situation.

What's interesting though, is that the iOS side marks cornerPoints() as _NonNull.
https://firebase.google.com/docs/reference/ios/firebasemlvision/api/reference/Protocols/FIRVisionText

.map<Point<num>>((dynamic item) => Point<num>(
item[0],
item[1],
))
.toList(),
text = data['text'];

/// Axis-aligned bounding rectangle of the detected text.
final Rectangle<num> boundingBox;
final List<Point<num>> _cornerPoints;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid num here and just use double?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr
num => int

I decided to use num because iOS returns doubles while android returns ints. With further investigating though, iOS only returns doubles for bounding box because CGRect uses doubles. So, I changed num to int to make it clearer to the user that the values will be whole numbers.

/// rectangle. Parts of the region could be outside of the image.
final List<Point<num>> cornerPoints;
/// Could be null even if text is found.
final Rectangle<num> boundingBox;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

),
]);

expect(blocks, <TextBlock>[]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or expect(blocks, isEmpty);

@bparrishMines bparrishMines merged commit f90755e into flutter:master Jun 28, 2018
@bparrishMines bparrishMines deleted the ml_vision_cleanup branch June 28, 2018 16:34
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants