Giter Club home page Giter Club logo

flutter_ocr_sdk's Introduction

flutter_ocr_sdk

A wrapper for Dynamsoft OCR SDK with MRZ detection model. It helps developers build Flutter applications to detect machine-readable zones (MRZ) in passports, travel documents, and ID cards.

Try MRZ Detection Example

Mobile: Android and iOS

cd example
flutter run 

Flutter Passport MRZ recognition

Web

cd example
flutter run -d chrome

Flutter MRZ recognition in web

Desktop: Windows and Linux

cd example
flutter run -d windows

# flutter run -d linux

Flutter MRZ OCR in Windows

Supported Platforms

  • Android
  • Web
  • Windows
  • Linux
  • iOS

Installation

Add flutter_ocr_sdk as a dependency in your pubspec.yaml file.

dependencies:
    ...
    flutter_ocr_sdk:

One More Step for Web

Include the JavaScript library of Dynamsoft Label Recognizer in your index.html file:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dlr.js"></script>

API Compatibility

Methods Android iOS Windows Linux macOS Web
Future<int?> init(String key) ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Future<int?> loadModel() ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Future<List<List<MrzLine>>?> recognizeByFile(String filename) ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Future<List<List<MrzLine>>?> recognizeByBuffer(Uint8List bytes, int width, int height, int stride, int format) ✔️ ✔️ ✔️ ✔️ ✔️ ✔️

Usage

  • Initialize the MRZ detector with a valid license key:

    FlutterOcrSdk _mrzDetector = FlutterOcrSdk();
    int? ret = await _mrzDetector.init( "DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==");
  • Load the MRZ detection model:

    await _mrzDetector.loadModel();
  • Recognize MRZ from an image file:

    List<List<MrzLine>>? results = await _mrzDetector.recognizeByFile(photo.path);
  • Recognize MRZ from an image buffer:

    ui.Image image = await decodeImageFromList(fileBytes);
    
    ByteData? byteData =
        await image.toByteData(format: ui.ImageByteFormat.rawRgba);
    
    List<List<MrzLine>>? results = await _mrzDetector.recognizeByBuffer(
          byteData.buffer.asUint8List(),
          image.width,
          image.height,
          byteData.lengthInBytes ~/ image.height,
          ImagePixelFormat.IPF_ARGB_8888.index);
  • Parse MRZ information:

    String information = '';
    if (results != null && results.isNotEmpty) {
        for (List<MrzLine> area in results) {
            if (area.length == 2) {
            information =
                MRZ.parseTwoLines(area[0].text, area[1].text).toString();
            } else if (area.length == 3) {
            information = MRZ
                .parseThreeLines(area[0].text, area[1].text, area[2].text)
                .toString();
            }
        }
    }

flutter_ocr_sdk's People

Contributors

yushulx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_ocr_sdk's Issues

OCR scan andorid + ios

I try it scan for andorid and IOS but I see , Android only scan horizontal and IOS only scan vertical.
I can andorid + ios scan vertical . Can the library do it?

Windows system not able to execute it and throwing and error!

Screenshot 2023-09-27 at 3 05 25 PM

Good day!,

I tried to run the OCR SDK for some of my work but was unable to do so because the system threw me an error similar to that in the shared Snapshot. Could someone perhaps take a look and fix it? and can also put this capability into practice for Mac OS.

I didn't recognize any text using your demo

Is it unusable? Identified without any results

List<List>? results = await mrzDetector.recognizeByBuffer(
byteData.buffer.asUint8List(),
image.width,
image.height,
byteData.lengthInBytes ~/ image.height,
ImagePixelFormat.IPF_BINARYINVERTED.index);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.