Giter VIP home page Giter VIP logo

anyline-ocr-flutter-module's Introduction

Anyline Flutter Plugin

pub package

Anyline is a mobile OCR SDK, which can be configured by yourself to scan all kinds of numbers, characters, text and codes.

The plugin enables the connection to the SDK via Flutter.

Requirements:

iOS Android
baseSDK >= 10 minSDK >= 19

Example

This is just a minimal example function to show how to use our plugin as quick as possible. For the code of our Flutter example app check out the anyline_demo module.

void scanWithAnyline() async {
  /// Instantiate the plugin.
  var anylinePlugin = AnylinePlugin();

  /// Load the config file which also includes the license key (for more info
  /// visit documentation.anyline.com).
  var config = await rootBundle.loadString("config/AnalogMeterConfig.json");

  /// Start the scanning process.
  var stringResult = await anylinePlugin.startScanning(config);

  /// Convert the stringResult to a Map to access the result fields. It is
  /// recommended to create result classes that fit your use case. For more
  /// information on that, visit the Flutter Guide on documentation.anyline.com.
  Map<String, dynamic> result = jsonDecode(stringResult);
}

Quick Start Guide

For a more in-depth guide, consider checking out the Anyline Flutter Guide on documentation.anyline.com.

1. Get a License

Get your trial license to try Anyline inside your app. Reach out to our sales team to get a commercial license.

2. Get the Anyline flutter plugin

Add this to your package's pubspec.yaml file:

dependencies:
  anyline_plugin: ^24.1.0

Install it with Flutter:

  $ flutter pub get

3. Import the plugin into your Dart file

import 'package:anyline_plugin/anyline_plugin.dart';

4. Add the config file to the assets in your pubspec.yaml

flutter:
  assets:
    - path-to-your-json-config

Add a JSON file with the proper structure and elements. The JSON config contains:

  1. The license key
  2. Options field with
  • AnylineSDK config parameter
  • “segment”: which contains the scanModes for the UI Segment (e.g. switch between Analog and Digital) - optional
  1. OCR field with (Only if you want to use the OCR module)
  • your custom training data
  • RegEx validation

If you want to get detailed information about the config JSON, check out the official documentation.

6. Call the Anyline component

Instantiate the Plugin

var anylinePlugin = AnylinePlugin();

Load config from file

var config = await rootBundle.loadString("your/Config/Path.json");

Start scanning and parse result

var resultString = await anylinePlugin.startScanning(config);

Currently the plugin does not provide seperate result classes, but this may be added in the future. For now feel free to create your own result class which fits your use case best. Alternatively, Flutter/Dart also supports serializing JSON using code generation libraries. To serialize the JSON string manually and convert it to a Map use jsonDecode() from dart:convert:

Map<String, dynamic> resultMap = jsonDecode(resultString);

From here you can access e.g. the image path of the cutout image at resultMap['imagePath'].

For detailed information on handling results and the result structure, check out our Anyline Flutter Guide on documentation.anyline.com.

7. Add TrainData to the OCR Module (optional)

If you are using the ANYLINE_OCR module, you'll have to add some traineddata. There are some predefined traineddata which you can find in the example app. Also the OCR Config has to reflect the path. Check the VoucherConfig.json in the example/config folder.

IMPORTANT: The trainedFiles have to be directly in the Asset folder in Android.

iOS

ios   
 └─── myTrainedData.traineddata

Android

android   
   └─── app
         └─── src
               └─── main
                      └─── assets
                             └─── myTrainedData.traineddata || myTrainedData.any

Additional Functions

getLicenseExpiryDate

Get the expiration date of the provided license. Returns a string.

Images

Keep in mind, all the images are saved in the cache directory of the app. For performance reasons, we only provide the path as string, so we don't have to transfer the whole image through the bridge. Please be aware, that you should not use the images in the cache directory for persistent storage, but store the images in a location of your choice for persistence.

License

See LICENSE file.

anyline-ocr-flutter-module's People

Contributors

kylestation avatar michaelkhuber avatar

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.