Flutter implementation of Google Mobile Vision.

Overview

flutter_mobile_vision

Codacy Badge pub package

Flutter implementation for Google Mobile Vision.

Based on Google Mobile Vision.

Android Samples -=- iOS Samples

Liked? Star the repo to support the project!

Features

  • Android

    • Barcode Scan
      • Front or Back camera.
      • Select preview sizes.
      • Simple scan.
      • Toggle torch.
      • Toggle auto focus.
      • Specify types of barcodes that will be read.
      • Tap to capture.
      • Select barcode type to be scanned.
      • Scan multiple barcodes.
      • Barcode coordinates.
      • Show barcode text.
      • Standard code.
    • Recognize Text
      • Front or Back camera.
      • Select preview sizes.
      • Simple OCR.
      • Toggle torch.
      • Toggle auto focus.
      • Multiple recognition.
      • Text language.
      • Text coordinates.
      • Hide recognized text.
      • Standard code.
    • Detect Faces
      • Front or Back camera.
      • Select preview sizes.
      • Simple detection.
      • Toggle torch.
      • Toggle auto focus.
      • Multiple detection.
      • Face coordinates.
      • Hide detection information.
      • Standard code.
    • Generalization of capture activities.
    • Choose between back and front camera.
    • Control camera FPS.
  • iOS

    • Barcode Scan
      • Future Tasks
    • Recognize Text
      • Future Tasks
    • Detect Faces
      • Future Tasks

Your feature isn't listed? Open a issue right now!

Screenshots

Usage

Example

To use this plugin :

  • add the dependency to your pubspec.yaml file:
  dependencies:
    flutter:
      sdk: flutter
    flutter_mobile_vision: ^0.1.3
  • add FlutterMobileVision.start() to initState():
@override
void initState() {
  super.initState();
  FlutterMobileVision.start().then((x) => setState(() {}));
}

or for a better implementation:

@override
void initState() {
  super.initState();
  FlutterMobileVision.start().then((previewSizes) => setState(() {
    _previewBarcode = previewSizes[_cameraBarcode].first;
    _previewOcr = previewSizes[_cameraOcr].first;
    _previewFace = previewSizes[_cameraFace].first;
  }));
}

Barcode

//...
List<Barcode> barcodes = [];
try {
  barcodes = await FlutterMobileVision.scan(
    flash: _torchBarcode,
    autoFocus: _autoFocusBarcode,
    formats: _onlyFormatBarcode,
    multiple: _multipleBarcode,
    waitTap: _waitTapBarcode,
    showText: _showTextBarcode,
    preview: _previewBarcode,
    camera: _cameraBarcode,
    fps: 15.0,
  );
} on Exception {
  barcodes.add(new Barcode('Failed to get barcode.'));
}
//...

Android

For Android, you must do the following before you can use the plugin:

  • Add the camera permission to your AndroidManifest.xml

    <uses-feature android:name="android.hardware.camera" />

    <uses-permission android:name="android.permission.CAMERA" />

  • Add the Barcode activity to your AndroidManifest.xml (after other activity nodes)

    <activity android:name="io.github.edufolly.fluttermobilevision.barcode.BarcodeCaptureActivity" />

iOS

If you can help, the community thanks. Your fork is needed. 😉


OCR

//...
List<OcrText> texts = [];
try {
  texts = await FlutterMobileVision.read(
    flash: _torchOcr,
    autoFocus: _autoFocusOcr,
    multiple: _multipleOcr,
    showText: _showTextOcr,
    previewSize: _previewOcr,
    preview: _previewOcr,
    camera: _cameraOcr,
    fps: 2.0,
  );
} on Exception {
  texts.add(new OcrText('Failed to recognize text.'));
}
//...

Android

For Android, you must do the following before you can use the plugin:

  • Add the camera permission to your AndroidManifest.xml

    <uses-feature android:name="android.hardware.camera" />

    <uses-permission android:name="android.permission.CAMERA" />

  • Add the OCR activity to your AndroidManifest.xml (after other activity nodes)

    <activity android:name="io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity" />

iOS

If you can help, the community thanks. Your fork is needed. 😉


Face Detection

//...
List<Face> faces = [];
try {
  faces = await FlutterMobileVision.face(
    flash: _torchFace,
    autoFocus: _autoFocusFace,
    multiple: _multipleFace,
    showText: _showTextFace,
    preview: _previewFace,
    camera: _cameraFace,
    fps: 15.0,
  );
} on Exception {
  faces.add(new Face(-1));
}
//...

Android

For Android, you must do the following before you can use the plugin:

  • Add the camera permission to your AndroidManifest.xml

    <uses-feature android:name="android.hardware.camera" />

    <uses-permission android:name="android.permission.CAMERA" />

  • Add the Face Detection activity to your AndroidManifest.xml (after other activity nodes)

    <activity android:name="io.github.edufolly.fluttermobilevision.face.FaceCaptureActivity" />

iOS

If you can help, the community thanks. Your fork is needed. 😉

Comments
  • Cannot Run After Install

    Cannot Run After Install

    I just add this plugin into my flutter project, I need the OCR plugin, I followed instruction like in Usage section, but I got this error when I start run my project.

    Launching lib\main.dart on Mi A2 Lite in debug mode...
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\util\AbstractCaptureActivity.java:9: error: cannot find symbol
    import android.support.v4.app.ActivityCompat;
                                 ^
      symbol:   class ActivityCompat
      location: package android.support.v4.app
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\barcode\BarcodeUpdateListener.java:3: error: package android.support.annotation does not exist
    import android.support.annotation.UiThread;
                                     ^
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:28: error: package android.support.annotation does not exist
    import android.support.annotation.Nullable;
                                     ^
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:29: error: package android.support.annotation does not exist
    import android.support.annotation.RequiresPermission;
                                     ^
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:30: error: package android.support.annotation does not exist
    import android.support.annotation.StringDef;
                                     ^
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSourcePreview.java:22: error: package android.support.annotation does not exist
    import android.support.annotation.RequiresPermission;
                                     ^
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\FlutterMobileVisionPlugin.java:8: error: cannot find symbol
    import android.support.v4.app.ActivityCompat;
                                 ^
      symbol:   class ActivityCompat
      location: package android.support.v4.app
    
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\FlutterMobileVisionPlugin.java:9: error: package android.support.v4.content does not exist
    import android.support.v4.content.ContextCompat;
                                     ^
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:147: error: cannot find symbol
    
        @StringDef({
         ^
    
      symbol:   class StringDef
      location: class CameraSource
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:160: error: cannot find symbol
        @StringDef({
         ^
      symbol:   class StringDef
      location: class CameraSource
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\barcode\BarcodeUpdateListener.java:9: error: cannot find symbol
        @UiThread
         ^
      symbol:   class UiThread
      location: interface BarcodeUpdateListener
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:344: error: cannot find symbol
        @RequiresPermission(Manifest.permission.CAMERA)
         ^
      symbol:   class RequiresPermission
      location: class CameraSource
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:379: error: cannot find symbol
        @RequiresPermission(Manifest.permission.CAMERA)
         ^
      symbol:   class RequiresPermission
    
      location: class CameraSource
    
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:534: error: cannot find symbol
        @Nullable
         ^
      symbol:   class Nullable
      location: class CameraSource
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:574: error: cannot find symbol
        @Nullable
    
         ^
      symbol:   class Nullable
      location: class CameraSource
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:622: error: cannot find symbol
        public void autoFocus(@Nullable AutoFocusCallback cb) {
                               ^
      symbol:   class Nullable
      location: class CameraSource
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSource.java:659: error: cannot find symbol
        public boolean setAutoFocusMoveCallback(@Nullable AutoFocusMoveCallback cb) {
                                                 ^
      symbol:   class Nullable
      location: class CameraSource
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSourcePreview.java:57: error: cannot find symbol
        @RequiresPermission(Manifest.permission.CAMERA)
         ^
    
      symbol:   class RequiresPermission
      location: class CameraSourcePreview
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSourcePreview.java:73: error: cannot find symbol
        @RequiresPermission(Manifest.permission.CAMERA)
         ^
      symbol:   class RequiresPermission
      location: class CameraSourcePreview
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\ui\CameraSourcePreview.java:94: error: cannot find symbol
        @RequiresPermission(Manifest.permission.CAMERA)
         ^
    
      symbol:   class RequiresPermission
      location: class CameraSourcePreview
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\util\AbstractCaptureActivity.java:83: error: cannot find symbol
                int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
                         ^
      symbol:   variable ActivityCompat
      location: class AbstractCaptureActivity<T>
      where T is a type-variable:
        T extends Graphic declared in class AbstractCaptureActivity
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\FlutterMobileVisionPlugin.java:149: error: cannot find symbol
                    if (ContextCompat.checkSelfPermission(registrar.activity(),
                        ^
      symbol:   variable ContextCompat
      location: class FlutterMobileVisionPlugin
    C:\Users\Developer\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_mobile_vision-0.1.3\android\src\main\java\io\github\edufolly\fluttermobilevision\FlutterMobileVisionPlugin.java:153: error: cannot find symbol
                        ActivityCompat.requestPermissions(registrar.activity(),
                        ^
      symbol:   variable ActivityCompat
      location: class FlutterMobileVisionPlugin
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    23 errors
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':flutter_mobile_vision:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 9s
    *******************************************************************************************
    The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
    See https://goo.gl/CP92wY for more information on the problem and how to fix it.
    *******************************************************************************************
    Gradle task assembleDebug failed with exit code 1
    Exited (sigterm)
    

    Is there something I've wrong or something I need to do to run with this plugins properly?

    opened by caktoy 7
  • Does this package supports android 6?

    Does this package supports android 6?

    I tried using the application with my phone with android 6 it doesn't open camera and say unable to recognize but it is working with android version 7. Can you guide me for its solution.

    opened by raziAkbar 5
  • Android Errors Out on Front Camera Landscape

    Android Errors Out on Front Camera Landscape

    I'm running the package on a Lenovo tablet and using the barcode scanning feature. I am using the front camera and noticed that when the tablet is in landscape mode with the front camera at the top of the device the app errors out when scanning with the following in the debug console:

    W/DynamiteModule(22489): Local module descriptor class for com.google.android.gms.vision.dynamite not found. I/DynamiteModule(22489): Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:1800 I/DynamiteModule(22489): Selected remote version of com.google.android.gms.vision.dynamite, version >= 1800 I/Vision (22489): Loading library libbarhopper.so I/Vision (22489): libbarhopper.so library load status: true D/AndroidRuntime(22489): Shutting down VM E/AndroidRuntime(22489): FATAL EXCEPTION: main E/AndroidRuntime(22489): Process: com.example.billoflading, PID: 22489 E/AndroidRuntime(22489): java.lang.RuntimeException: set display orientation failed E/AndroidRuntime(22489): at android.hardware.Camera.setDisplayOrientation(Native Method) E/AndroidRuntime(22489): at io.github.edufolly.fluttermobilevision.ui.CameraSource.setRotation(CameraSource.java:1032) E/AndroidRuntime(22489): at io.github.edufolly.fluttermobilevision.ui.CameraSource.createCamera(CameraSource.java:784) E/AndroidRuntime(22489): at io.github.edufolly.fluttermobilevision.ui.CameraSource.start(CameraSource.java:384) E/AndroidRuntime(22489): at io.github.edufolly.fluttermobilevision.ui.CameraSourcePreview.startIfReady(CameraSourcePreview.java:97) E/AndroidRuntime(22489): at io.github.edufolly.fluttermobilevision.ui.CameraSourcePreview.access$200(CameraSourcePreview.java:35) E/AndroidRuntime(22489): at io.github.edufolly.fluttermobilevision.ui.CameraSourcePreview$SurfaceCallback.surfaceCreated(CameraSourcePreview.java:121) E/AndroidRuntime(22489): at android.view.SurfaceView.updateWindow(SurfaceView.java:632) E/AndroidRuntime(22489): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:162) E/AndroidRuntime(22489): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944) E/AndroidRuntime(22489): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2205) E/AndroidRuntime(22489): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254) E/AndroidRuntime(22489): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6343) E/AndroidRuntime(22489): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874) E/AndroidRuntime(22489): at android.view.Choreographer.doCallbacks(Choreographer.java:686) E/AndroidRuntime(22489): at android.view.Choreographer.doFrame(Choreographer.java:621) E/AndroidRuntime(22489): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) E/AndroidRuntime(22489): at android.os.Handler.handleCallback(Handler.java:751) E/AndroidRuntime(22489): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime(22489): at android.os.Looper.loop(Looper.java:154) E/AndroidRuntime(22489): at android.app.ActivityThread.main(ActivityThread.java:6119) E/AndroidRuntime(22489): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(22489): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) E/AndroidRuntime(22489): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

    This doesn't happen when using the back camera, or when using any other orientation with the front camera. For example, when scanning with the front camera in landscape mode and the camera at the bottom of the tablet, it does not error out.

    Any ideas?

    opened by kstokes-asco 5
  • OCR Method always returning the exception

    OCR Method always returning the exception

    Hi We are using this OCRText widget library for our project, it is running okay, but after scanning the text, it is always throwing the error. even though the text is recognised on screen. code block as follows:

    /// /// OCR Method /// Future _read() async { List texts = []; try { texts = await FlutterMobileVision.read( flash: _torchOcr, autoFocus: _autoFocusOcr, multiple: _multipleOcr, showText: _showTextOcr, camera: _cameraOcr, fps: 2.0, ); } on Exception { texts.add(new OcrText('Failed to recognize text.'));

    }
    
    if (!mounted) return;
    setState(() => _textsOcr = texts);
    

    }

    screenshot_20180831-140041

    opened by KVManpreetam 5
  • the program crashes, when click the screen or return

    the program crashes, when click the screen or return

    can you give me some suggestions, thanks !

      _startOCRScan() async {
        List<OcrText> list = List();
        try {
          list = await FlutterMobileVision.read(
            waitTap: true,
            fps: 5,
            multiple: true,
          );
          for (OcrText text in list) {
            print('value is ${text.value}');
          }
        } catch (e) {
          print(e.toString());
        }    
      }
    

    Here is debug info:

    D/skia    (26352): onFlyCompress
    D/skia    (26352): onFlyCompress
    D/skia    (26352): onFlyCompress
    D/Camera  (26352): app passed NULL surface
    I/flutter (26352): value is B
    I/flutter (26352): value is T
    I/flutter (26352): value is U
    I/flutter (26352): value is 6
    I/flutter (26352): value is 8
    I/flutter (26352): value is M
    I/flutter (26352): value is G
    I/flutter (26352): value is H
    I/flutter (26352): value is N
    D/AndroidRuntime(26352): Shutting down VM
    E/AndroidRuntime(26352): FATAL EXCEPTION: main
    E/AndroidRuntime(26352): Process: com.example.one, PID: 26352
    E/AndroidRuntime(26352): java.lang.RuntimeException: Unable to destroy activity {com.example.one/io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference
    E/AndroidRuntime(26352):        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5111)
    E/AndroidRuntime(26352):        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5140)
    E/AndroidRuntime(26352):        at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
    E/AndroidRuntime(26352):        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
    E/AndroidRuntime(26352):        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    E/AndroidRuntime(26352):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
    E/AndroidRuntime(26352):        at android.os.Handler.dispatchMessage(Handler.java:106)
    E/AndroidRuntime(26352):        at android.os.Looper.loop(Looper.java:223)
    E/AndroidRuntime(26352):        at android.app.ActivityThread.main(ActivityThread.java:7656)
    E/AndroidRuntime(26352):        at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime(26352):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    E/AndroidRuntime(26352):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    E/AndroidRuntime(26352): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference
    E/AndroidRuntime(26352):        at io.github.edufolly.fluttermobilevision.ui.CameraSource$FrameProcessingRunnable.release(CameraSource.java:1142)
    E/AndroidRuntime(26352):        at io.github.edufolly.fluttermobilevision.ui.CameraSource$FrameProcessingRunnable.access$900(CameraSource.java:1119)
    E/AndroidRuntime(26352):        at io.github.edufolly.fluttermobilevision.ui.CameraSource.release(CameraSource.java:334)
    E/AndroidRuntime(26352):        at io.github.edufolly.fluttermobilevision.ui.CameraSourcePreview.release(CameraSourcePreview.java:85)
    E/AndroidRuntime(26352):        at io.github.edufolly.fluttermobilevision.util.AbstractCaptureActivity.onDestroy(AbstractCaptureActivity.java:124)
    E/AndroidRuntime(26352):        at android.app.Activity.performDestroy(Activity.java:8245)
    E/AndroidRuntime(26352):        at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1344)
    E/AndroidRuntime(26352):        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5096)
    E/AndroidRuntime(26352):        ... 11 more
    I/Process (26352): Sending signal. PID: 26352 SIG: 9
    Lost connection to device.
    
    opened by answer0732 4
  • OCR crashes when tapping return or when tapping on recognized text, even when configured properly

    OCR crashes when tapping return or when tapping on recognized text, even when configured properly

    Greetings, I've configured the package as it was intended, added the OCR activity and needed permissions, but when I tap on the scanning screen I am greeted by a crash of my entire app.

    This is what the debug console has to say:

    W/ActivityThread(29080): SCHED: com.example.finapp/io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity [87, r=750ms, a=110ms, w=26173ms]
    D/Camera  (29080): app passed NULL surface
    W/Activity(29080): Slow Operation: Activity com.example.finapp/io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity onPause took 294ms
    D/AndroidRuntime(29080): Shutting down VM
    E/AndroidRuntime(29080): FATAL EXCEPTION: main
    E/AndroidRuntime(29080): Process: com.example.finapp, PID: 29080
    E/AndroidRuntime(29080): java.lang.RuntimeException: Unable to destroy activity {com.example.finapp/io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference
    E/AndroidRuntime(29080): 	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5056)
    E/AndroidRuntime(29080): 	at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5085)
    E/AndroidRuntime(29080): 	at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
    E/AndroidRuntime(29080): 	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
    E/AndroidRuntime(29080): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    E/AndroidRuntime(29080): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
    E/AndroidRuntime(29080): 	at android.os.Handler.dispatchMessage(Handler.java:107)
    E/AndroidRuntime(29080): 	at android.os.Looper.loop(Looper.java:224)
    E/AndroidRuntime(29080): 	at android.app.ActivityThread.main(ActivityThread.java:7590)
    E/AndroidRuntime(29080): 	at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime(29080): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    E/AndroidRuntime(29080): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
    E/AndroidRuntime(29080): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference
    E/AndroidRuntime(29080): 	at io.github.edufolly.fluttermobilevision.ui.CameraSource$FrameProcessingRunnable.release(CameraSource.java:1142)
    E/AndroidRuntime(29080): 	at io.github.edufolly.fluttermobilevision.ui.CameraSource$FrameProcessingRunnable.access$900(CameraSource.java:1119)
    E/AndroidRuntime(29080): 	at io.github.edufolly.fluttermobilevision.ui.CameraSource.release(CameraSource.java:334)
    E/AndroidRuntime(29080): 	at io.github.edufolly.fluttermobilevision.ui.CameraSourcePreview.release(CameraSourcePreview.java:85)
    E/AndroidRuntime(29080): 	at io.github.edufolly.fluttermobilevision.util.AbstractCaptureActivity.onDestroy(AbstractCaptureActivity.java:124)
    E/AndroidRuntime(29080): 	at android.app.Activity.performDestroy(Activity.java:8180)
    E/AndroidRuntime(29080): 	at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1342)
    E/AndroidRuntime(29080): 	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5041)
    E/AndroidRuntime(29080): 	... 11 more
    I/Process (29080): Sending signal. PID: 29080 SIG: 9
    Lost connection to device.
    Exited (sigterm)
    

    Is there any way to fix this, I used the 0.1.4 and 0.1.3 versions, both failed. My code is as follows:

    import 'package:flutter_mobile_vision/flutter_mobile_vision.dart';
    
    Future<Null> _read() async {
      List<OcrText> texts = [];
      try {
        texts = await FlutterMobileVision.read(
          camera: FlutterMobileVision.CAMERA_BACK,
          waitTap: true,
          showText: true,
        );
      } on Exception {
        texts.add(
          OcrText('Failed to recognize text'),
        );
      }
    }
    <...>
    @override
    void initState() {
      super.initState();
      FlutterMobileVision.start();
    }
    <...>
    floatingActionButton: FloatingActionButton.extended(
      onPressed: _read,
      icon: Icon(Icons.camera_alt_rounded),
      backgroundColor: Colors.orange,
      label: Text("Scan"),
    ),
    

    And the AndroidManifest.xml in main is as follows:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.finapp">
      <uses-feature android:name="android.hardware.camera" />
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.CAMERA" />
      <application android:label="finapp" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="true">
        <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
          <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
          <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
          <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
        </activity>
        <activity android:name="io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity" />
        <meta-data android:name="flutterEmbedding" android:value="2" />
      </application>
    </manifest>
    
    opened by MatijaNovosel 3
  • 真机调试无法调用相机

    真机调试无法调用相机

    W/DynamiteModule( 1782): Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found. W/DynamiteModule( 1782): Failed to retrieve remote module version. W/GooglePlayServicesUtil( 1782): Google Play Store is missing. I/DynamiteModule( 1782): Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0 W/GooglePlayServicesUtil( 1782): Google Play Store is missing. W/DynamiteModule( 1782): Local module descriptor class for com.google.android.gms.vision.ocr not found. I/DynamiteModule( 1782): Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:0 E/Vision ( 1782): Error loading module com.google.android.gms.vision.ocr optional module true: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0. I/SendBroadcastPermission( 1782): action:com.google.android.gms.vision.DEPENDENCY, mPermissionType:0 W/TextNativeHandle( 1782): Native handle not yet available. Reverting to no-op handle. W/DynamiteModule( 1782): Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found. W/GooglePlayServicesUtil( 1782): Google Play Store is missing. I/DynamiteModule( 1782): Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0 W/GooglePlayServicesUtil( 1782): Google Play Store is missing. W/DynamiteModule( 1782): Local module descriptor class for com.google.android.gms.vision.ocr not found. I/DynamiteModule( 1782): Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:0

    opened by liuswong 3
  • Deny Camera Permission crashed the app

    Deny Camera Permission crashed the app

    Hi, I found out that if I deny permission for camera, it will crash. Please find the log below Thank you

    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9010, result=13, data=null} to activity {.MainActivity}: java.lang.IllegalStateException: Reply already submitted
            at android.app.ActivityThread.deliverResults(ActivityThread.java:4196)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:4239)
            at android.app.ActivityThread.-wrap20(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1599)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:165)
            at android.app.ActivityThread.main(ActivityThread.java:6365)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
         Caused by: java.lang.IllegalStateException: Reply already submitted
            at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:174)
            at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:199)
            at io.github.edufolly.fluttermobilevision.FlutterMobileVisionPlugin.onActivityResult(FlutterMobileVisionPlugin.java:188)
            at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:210)
            at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:139)
            at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:138)
            at android.app.Activity.dispatchActivityResult(Activity.java:7116)
    
    opened by sleith 3
  • IllegalStateException

    IllegalStateException

    Possibly related to #7 - except it happens when permission is granted. It crashes the first time (when the permission dialog is there), and then it works just fine.

    java.lang.RuntimeException: 
      at android.app.ActivityThread.deliverResults (ActivityThread.java:4360)
      at android.app.ActivityThread.handleSendResult (ActivityThread.java:4402)
      at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:49)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1808)
      at android.os.Handler.dispatchMessage (Handler.java:106)
      at android.os.Looper.loop (Looper.java:193)
      at android.app.ActivityThread.main (ActivityThread.java:6669)
      at java.lang.reflect.Method.invoke (Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
    Caused by: java.lang.IllegalStateException: 
      at io.flutter.view.FlutterNativeView$1.reply (FlutterNativeView.java:174)
      at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error (MethodChannel.java:199)
      at io.github.edufolly.fluttermobilevision.FlutterMobileVisionPlugin.onActivityResult (FlutterMobileVisionPlugin.java:188)
      at io.flutter.app.FlutterPluginRegistry.onActivityResult (FlutterPluginRegistry.java:210)
      at io.flutter.app.FlutterActivityDelegate.onActivityResult (FlutterActivityDelegate.java:139)
      at io.flutter.app.FlutterActivity.onActivityResult (FlutterActivity.java:138)
      at android.app.Activity.dispatchActivityResult (Activity.java:7454)
      at android.app.ActivityThread.deliverResults (ActivityThread.java:4353)
    
      Future scan() async {
        List<Barcode> barcodes = [];
        try {
          barcodes = await FlutterMobileVision.scan(
            fps: 15.0,
          );
          SharedPreferences prefs = await SharedPreferences.getInstance();
          prefs.setString("usr_idNumber", barcodes[0].rawValue);
          setState(() {
            id_number = barcodes[0].rawValue;
          });
        } on Exception {
          setState(() {
                  errorText = "An error occured.";
                });
          barcodes.add(new Barcode('Failed to get barcode.'));
        }
      }
    
    opened by nikhiljha 3
  • Crash when the permission is not granted on Android

    Crash when the permission is not granted on Android

    Hello,

    On Android, the first time the application is opened (or if the camera permission is never granted), the app will crash.

    In the onActivityResult method, if the resultCode is an error, you are never checking if the intent is null. In the case where the permission is not granted, the intent is null, so the app will crash.

    bug 
    opened by g123k 3
  • Face Recognition

    Face Recognition

    Hi,

    Thanks for the plugin and demo. I am wondering when we can implement the Face Recognition in both iOS and android flutter app? When detected faces how to get Face coordinates as Face Recognition. and save it to sql database or firebase database? Thanks

    opened by NTMS2017 3
  • App crashes!

    App crashes!

    When i tap on screen, App crashes by showing following exception message:

    java.lang.RuntimeException: Unable to destroy activity {com.example.ocr_project/io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference

    opened by PrameshKarki 2
  • Nullpointer exception in CameraSource.java

    Nullpointer exception in CameraSource.java

    The release()-method in the CameraSource.java file causes a NullPointer exception, becuase the processingThread seems to be null. This should close Issue #71. I referred the direct link below

    https://github.com/edufolly/flutter_mobile_vision/blob/7019a96c8ceadfc0772f0671117af3c221d3f9cc/android/src/main/java/io/github/edufolly/fluttermobilevision/ui/CameraSource.java#L1142

    opened by Huntler 1
  • https://medium.com/flutterdevs/ocr-in-flutter-5144ed361239

    https://medium.com/flutterdevs/ocr-in-flutter-5144ed361239

    i copied this code and every thing went right, i'd like to add a direct translation on the camera screen where user can choose the language.. and i observed that this plugin can only detect english letters(not arabic or indian..), so is there a way that make it detect any language(like ml_vision plugin)?

    opened by IbrahimHasan93 0
  • null safe implimentation

    null safe implimentation

    The library 'package:flutter_mobile_vision/flutter_mobile_vision.dart' is legacy, and should not be imported into a null safe library.\nTry migrating the imported library.

    opened by Yoda-Man 3
  • App Crashes on OCR

    App Crashes on OCR

    Future _read() async { List texts = []; try { texts = await FlutterMobileVision.read( waitTap: true, flash: _torchOcr, autoFocus: _autoFocusOcr, multiple: _multipleOcr, showText: _showTextOcr, preview: _previewOcr, camera: _ocrCamera, fps: 2.0, ); setState(() { currentLogItem.washOption = texts[0].value; }); } on Exception { texts.add(OcrText('Failed to recognize text')); } } }

    opened by Yoda-Man 10
Releases(0.1.2)
Owner
Eduardo Folly
[father, brewer, coder]
Eduardo Folly
A unique flutter application aimed at helping people getting their vitals using Photoplethysmography and Computer Vision

A unique flutter application aimed at helping people getting their vitals using Photoplethysmography and Computer Vision Current Goals: Use the camera

Smaranjit Ghose 37 Dec 27, 2022
A flutter widget that show the camera stream and allow ML vision recognition on it, it allow you to detect barcodes, labels, text, faces...

Flutter Camera Ml Vision A Flutter package for iOS and Android to show a preview of the camera and detect things with Firebase ML Vision. Installation

Rushio Consulting 257 Jan 2, 2023
Dart GraphQL server implementation. Utilities, code generator, examples and reference implementation.

Leto - GraphQL Server A complete implementation of the official GraphQL specification in the Dart programming language. Inspired by graphql-js, async-

Juan Manuel Castillo 29 Nov 27, 2022
Music reader for online data (Google Drive implementation). Cross platform goal : iOS, Android, MacOS, Windows

omusic A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

JeanNicolasdeLamballerie 0 Nov 30, 2021
In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google Admob Package.

?? Monetizing Flutter apps with Google AdMob ?? In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google A

SnippetCoder 14 Nov 30, 2022
A Translator App Which is Build using Flutter, Speech To Text, Google ML Kit, Google Translator and Text To Speech.

AI Translator This is a Translator App Which is Build using Flutter, Speech To Text, Google ML Kit, Google Translator and Text To Speech. Download App

null 4 Jul 16, 2022
A Flutter plugin for the Google Mobile Ads SDK

A Flutter plugin for the Google Mobile Ads SDK

Google Ads 251 Jan 2, 2023
Facebook mediation plugin for Google Mobile Ads (Flutter).

Facebook mediation plugin for Google Mobile Ads Flutter Google Mobile Ads Flutter mediation plugin for Facebook Audience Network. Use this package as

Taeho Kim 4 Nov 14, 2022
Google IO Mobile Version (Fake)

fake_google_io Fake Google IO made with flutter (Not official!) Inspiration This application was made to enliven the Google I/O 2021 event which was h

Irvan Lutfi Gunawan 4 May 20, 2021
This is a clone of the Google News mobile app.

gnewsclone This is a clone of the Google News mobile app. I will try to develop it as close as possible. I am new to Flutter, and I might end refactor

Degreat 10 Sep 18, 2022
Learn Flutter on Flutter! A widget directory with implementation samples!

Fludget Browse through a variety of widgets used in flutter This application is developed to learn Flutter using Flutter. Different widgets used in fl

ACM VIT 29 Nov 23, 2022
Paper is a implementation of Flx Design System for Flutter

Paper is a implementation of Flx Design System for Flutter. Installing Add a lines like this to your pubspec.yaml. dependencies: paper: git:

Flx Team 3 Nov 21, 2021
Flutter implementation of Figma's corner smoothing.

Figma Squircle Flutter implementation of Figma's corner smoothing. Usage Decoration The SmoothRectangleBorder can be provided to a regular ShapeDecora

Aloïs Deniel 88 Dec 14, 2022
A Flutter package with custom implementation of Drawer

Flutter Zoom Drawer A Flutter package with custom implementation of the Side Menu (Drawer) Getting Started To start using this package, add flutter_zo

null 335 Dec 22, 2022
Backdrop implementation in flutter.

backdrop Backdrop implementation in flutter. This widget is in active development. Any contribution, idea, criticism or feedback is welcomed. Quick li

Harsh Bhikadia 6 Jan 6, 2022
a python-like bytes_io implementation for dart

bytes_io A python-like bytes_io implementation for dart A powerful helper for processing raw binary data Usage A simple usage example: import 'package

Kelly 5 Aug 31, 2022
A bugless implementation of BigDecimal in Dart based on Java's BigDecimal

big_decimal A bugless implementation of BigDecimal in Dart based on Java's BigDecimal Installation Add the following to your pubspec.yaml: dependencie

null 18 Jul 27, 2022
Libwinmedia implementation of just_audio.

just_audio_libwinmedia The libwinmedia implementation of [just_audio][https://github.com/ryanheise/just_audio]. Installation Add the just_audio_libwin

Bruno D'Luka 12 Oct 22, 2022
Implementation of FIrebase CRUD App.

firebase_crud_app_flutter A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to ge

Chinmay Munje 0 Nov 4, 2021