flutter_ocr_sdk

A wrapper for Dynamsoft OCR SDK, focusing on Passport MRZ recognition.

Try Passport MRZ Example

cd example
flutter run -d <device>

Flutter Passport MRZ recognition

Usage

  • Download the model package. Unzip model files to model/ folder, and configure assets in pubspec.yaml:

      assets:
      - model/
      - model/CharacterModel/
    
  • Initialize the object and load the model path by the asset path:

      _textRecognizer = FlutterOcrSdk();
      _textRecognizer.loadModel('model/');
    
  • Recognize passport MRZ by setting an image file and the template name locr. The template name is defined in model/wholeImgMRZTemplate.json:

      String ret = await _textRecognizer.recognizeByFile(image?.path, 'locr');
    
  • Recognize passport MRZ by setting an image buffer (E.g. CameraImage) and the template name locr:

      CameraImage availableImage;
      String ret = await _textRecognizer.recognizeByFile(availableImage.planes[0].bytes,
                availableImage.width,
                availableImage.height,
                availableImage.planes[0].bytesPerRow,
                format, 'locr');
    
  • Set the organization ID if you have a Dynamsoft account:

      await _textRecognizer.setOrganizationID('YOUR-ID');
    

Libraries

flutter_ocr_sdk
mrz