forked from firebase/flutterfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code cleanup and added metadata for ML Vision (firebase#631)
- Loading branch information
1 parent
0aee5a1
commit 3189324
Showing
13 changed files
with
312 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. | ||
* Initial release with text detector. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
TODO: Add your license here. | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following disclaimer | ||
// in the documentation and/or other materials provided with the | ||
// distribution. | ||
// * Neither the name of Google Inc. nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,70 @@ | ||
# firebase_ml_vision | ||
# Google ML Kit for Firebase | ||
|
||
A new Flutter plugin. | ||
[![pub package](https://img.shields.io/pub/v/firebase_ml_vision.svg)](https://pub.dartlang.org/packages/firebase_ml_vision) | ||
|
||
## Getting Started | ||
A Flutter plugin to use the [Google ML Kit for Firebase API](https://firebase.google.com/docs/ml-kit/). | ||
|
||
For Flutter plugins for other Firebase products, see [FlutterFire.md](https://github.com/flutter/plugins/blob/master/FlutterFire.md). | ||
|
||
*Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome! | ||
|
||
## 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). | ||
|
||
### Android | ||
Optional but recommended: If you use the on-device API, configure your app to automatically download the ML model to the device after your app is installed from the Play Store. To do so, add the following declaration to your app's AndroidManifest.xml file: | ||
|
||
```manifest | ||
<application ...> | ||
... | ||
<meta-data | ||
android:name="com.google.firebase.ml.vision.DEPENDENCIES" | ||
android:value="ocr" /> | ||
<!-- To use multiple models: android:value="ocr,model2,model3" --> | ||
</application> | ||
``` | ||
|
||
## On-device Text Recognition | ||
|
||
To use the on-device text recognition model, run the text detector as described below: | ||
|
||
1. Create a `FirebaseVisionImage` object from your image. | ||
|
||
For help getting started with Flutter, view our online | ||
[documentation](https://flutter.io/). | ||
To create a `FirebaseVisionImage` from an image `File` object: | ||
|
||
```dart | ||
final File imageFile = getImageFile(); | ||
final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(imageFile); | ||
``` | ||
|
||
2. Get an instance of `TextDetector` and pass `visionImage` to `detectInImage().` | ||
|
||
```dart | ||
final TextDetector detector = FirebaseVision.instance.getTextDetector(); | ||
final List<TextBlock> blocks = await detector.detectInImage(visionImage); | ||
detector.close(); | ||
``` | ||
|
||
3. Extract text and text locations from blocks of recognized text. | ||
|
||
```dart | ||
for (TextBlock block in textLocations) { | ||
final Rectangle<num> boundingBox = block.boundingBox; | ||
final List<Point<num>> cornerPoints = block.cornerPoints; | ||
final String text = block.text; | ||
for (TextLine line in block.lines) { | ||
// ... | ||
for (TextElement element in line.elements) { | ||
// ... | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Getting Started | ||
|
||
For help on editing plugin code, view the [documentation](https://flutter.io/platform-plugins/#edit-code). | ||
See the `example` directory for a complete sample app using Google ML Kit for Firebase. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.