-
Notifications
You must be signed in to change notification settings - Fork 9.8k
WIP: Live MLKit vision detection using the camera plugin #688
WIP: Live MLKit vision detection using the camera plugin #688
Conversation
resulting bounding box was inaccurate.
Android only for now. pulled impl from camera flutter plugin.
make stream handling more appealing
this is in preparation to integrate ML Kit recognition of frames.
not yet returning any data to the Flutter app.
defect: preview image is not oriented correctly. detector does not work properly when the preview image is oriented correctly.
screen coordinates are still not translating properly
refactor detectors so that we can send messages back to flutter on Results and Sinks
there are some defects on both platforms that need to be resolved. Android & iOS: barcode detector boundaries are wrong iOS: MLKit detector doesn't work when preview image is not landscape Android: Live text detection block boundaries are off. iOS: utilizing some iOS 10 APIs, need to find iOS 8 work-arounds
# Conflicts: # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/BarcodeDetector.java # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/Detector.java # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/FaceDetector.java # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/FirebaseMlVisionPlugin.java # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/LabelDetector.java # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/TextDetector.java # packages/firebase_ml_vision/example/lib/detector_painters.dart # packages/firebase_ml_vision/example/lib/main.dart # packages/firebase_ml_vision/ios/Classes/BarcodeDetector.m # packages/firebase_ml_vision/ios/Classes/FaceDetector.m # packages/firebase_ml_vision/ios/Classes/FirebaseMlVisionPlugin.h # packages/firebase_ml_vision/ios/Classes/FirebaseMlVisionPlugin.m # packages/firebase_ml_vision/ios/Classes/TextDetector.m # packages/firebase_ml_vision/lib/src/barcode_detector.dart
# Conflicts: # packages/firebase_ml_vision/android/build.gradle # packages/firebase_ml_vision/example/android/build.gradle
also, fix two errors in BarcodeDetector.java: - TYPE_DRIVER_LICENSE barcodeMap key copy/paste error - TYPE_CALENDAR_EVENT typeValue not entered into barcodeMap
# Conflicts: # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/BarcodeDetector.java # packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision/LabelDetector.java # packages/firebase_ml_vision/ios/Classes/FirebaseMlVisionPlugin.m # packages/firebase_ml_vision/ios/Classes/LabelDetector.m # packages/firebase_ml_vision/lib/src/firebase_vision.dart
This will help us add a live preview without re-implementing the camera
need to add code to handle delivery of detector data to the UI.
…ra_plugin # Conflicts: # packages/firebase_ml_vision/example/lib/main.dart # packages/firebase_ml_vision/lib/src/firebase_vision.dart
This is along the lines of what I was considering as a solution. I was thinking of three solutions:
I think the best solution would be three, but we don't have anyone on the team that has time to implement or facilitate such a large change all at once. My only issue with this PR is that it requires changes in MainActivity, which is what we usually try to avoid. I think to pass images between plugins on the platform side alone would require changing the framework which isn't in my area of expertise. If you are still in need of an official solution, I just started working on solution 2. I believe it is the simplest to implement of the three and the only drawback is the speed of which the images are scanned would be slow. I should hopefully get that finished and reviewed within the next week or two. I apologize for keeping you block. |
@bparrishMines thanks for the response. I appreciate the value in making sure that this takes the correct shape and so in the interim I've implemented an alternate barcode scanning plugin for my app so that I'm no longer blocked. The alternate plugin just opens up native screens and passes back the scanned code. This is fine, but I'm still motivated to help find a way to get the live barcode scanning into Flutter because I believe that will provide the best experience to developers and end users. I've been thinking a lot about this over the past few weeks and I believe I'm still partial to solution I'm motivated and more than willing to help flesh out my idea with modifications to the framework, although I'm not sure where to start with contributions to Flutter proper yet. I'll go see if I can find some contribution docs, and if you have resources you could point me to, I would appreciate it. |
@bparrishMines When you have a minute, would you mind looking at this with @dustin-graham? Looks like there are test failures we need to wrap up, and I know Dustin was happy to wrap up work on it. Thanks! |
@bparrishMines Just saw your demo at FlutterLive. Great job! How did you decide to handle shuttling data from the Camera to MLKit? I would still like to be involved in this effort if I can. |
@dustin-graham Looks like he does just that, the solution 2 he started working on. Looked pretty fast to me judging from the live show. You made a real effort with this PR Dustin and I hope you get the chance to chime in on the work of the implementation he got going. Cheers |
@PerLycke Thanks! Yeah the results he showed were very encouraging. |
Thanks @dustin-graham ! We implemented it by passing bytes from the camera plugin -> dart -> ML Kit plugin. The PR's used in the demo were: #900 and #901. But recently, we decided that they could be better implemented and started a second iteration of these PRs. The process still requires some optimizations, but here is the new PR for the camera side: #965 and the branch for the ML Kit side: master...bparrishMines:mlkit_android_2. Feedback is always welcomed! |
@bparrishMines Looking through the code I notice there's no factory constructor for creating an instance of a FirebaseVisionImage from a CameraImage. Thinking as we're streaming a CameraImage now and not bytes. Any plans for a constructor like that? |
Maurice, thanks for the reply. I'll go take a look at those soon. The demo
you showed looked great. Have you guys taken some time to profile this
solution to measure the performance hit of translating to dart and back?
That was what I was primarily worried about in my work and so I tried to
keep things native as much as possible. Now that there is a working
reference, it would be nice to measure how valid that worry is. Thanks
again!
…On Fri, Dec 7, 2018, 3:29 AM Maurice Parrish ***@***.*** wrote:
Thanks @dustin-graham <https://github.com/dustin-graham> !
We implemented it by passing bytes from the camera plugin -> dart -> ML
Kit plugin.
The PR's used in the demo were: #900
<#900> and #901
<#901>. But recently, we decided
that they could be better implemented and started a second iteration of
these PRs.
The process still requires some optimizations, but here is the new PR for
the camera side: #965 <#965> and
the branch for the ML Kit side: master...bparrishMines:mlkit_android_2
<master...bparrishMines:mlkit_android_2>
.
Feedback is always welcomed!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#688 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA6lu7OPW2Tuhp-iG6eK8BM31gGV63HBks5u2kLygaJpZM4VjDxO>
.
|
@PerLycke I'm leaning towards just keeping the I considered a Here is an example of how to use to use it: https://github.com/bparrishMines/mlkit_demo/blob/master/lib/face_expression_reader.dart#L66 It takes quite a bit of code, but I think this does a better job of paving the road for expanding the API. |
@dustin-graham Unfortunately, I don't have detailed metrics of passing images. Although, passing a 1920x1080 image from platform -> dart -> platform took about 100ms on a Moto G5 Plus, which is a mid-range android phone from 2017. This suited our needs for the Flutter Live demo. However, ML Kit recommends using low resolution images anyways, so you could make it faster with smaller images. I will share a PR soon that would allow people to test out the performance themselves too. If you need the absolute best performance, forking the camera plugin and adding ML Kit to it would be the best solution. Combining the camera plugin with the ML Kit plugin should also be pretty straight forward. |
Also, do you mind if we close this PR and continue talking here: flutter/flutter#19274 or here: #965 |
Sure. Thanks for the replies.
…On Thu, Dec 13, 2018, 1:11 PM Maurice Parrish ***@***.*** wrote:
Also, do you mind if we close this PR and continue talking here:
flutter/flutter#19274 <flutter/flutter#19274>
or here: #965 <#965>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#688 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA6lu2MF-M3DBJgG9z4YKDEVzaDwYjzmks5u4rSLgaJpZM4VjDxO>
.
|
This is a prototype for utilizing the
camera
plugin rather than implementing a custom camera setup inside offirebase_ml_vision
. This was done based on feedback in flutter/flutter#19274.The way this works is for
firebase_ml_vision
to depend oncamera
. Bothcamera
andfirebase_ml_vision
have an interface that the host application can add to the MainActivity. The MainActivity then facilitates the communication of new preview images from the camera to thefirebase_ml_vision
plugin. This does not feel like a polished solution, just something that came to mind that would work for a quick prototype. I would like to find a more "automatic" way to pass data between these plugins. I'm sure there is one. Once the image data gets to thefirebase_ml_vision
plugin, it can be processed and the results can be send to an EventChannel that the Dart side is observing.I think this should be a pretty good way to implement this feature.
@bparrishMines , is this what you had in mind?