flutter_ocr_sdk 1.0.0 copy "flutter_ocr_sdk: ^1.0.0" to clipboard
flutter_ocr_sdk: ^1.0.0 copied to clipboard

discontinued

A wrapper for Dynamsoft OCR SDK, detecting MRZ in passports, travel documents, and ID cards.

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/dynamsoft-label-recognizer@2.2.11/dist/dlr.js"></script>

API Compatibility #

Methods Android iOS Windows Linux macOS Web
Future<int?> init(String path, 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 the SDK path (Web Only) and a valid license key:

    FlutterOcrSdk _mrzDetector = FlutterOcrSdk();
    int? ret = await _mrzDetector.init("https://cdn.jsdelivr.net/npm/dynamsoft-label-recognizer@2.2.11/dist/", "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();
            }
        }
    }
    
19
likes
0
pub points
78%
popularity

Publisher

verified publisheryushulx.me

A wrapper for Dynamsoft OCR SDK, detecting MRZ in passports, travel documents, and ID cards.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, js, path, path_provider, plugin_platform_interface

More

Packages that depend on flutter_ocr_sdk