anyline 24.0.0-dev.1 copy "anyline: ^24.0.0-dev.1" to clipboard
anyline: ^24.0.0-dev.1 copied to clipboard

discontinuedreplaced by: anyline_plugin
outdated

Anyline OCR Module

 _____         _ _         
|  _  |___ _ _| |_|___ ___ 
|     |   | | | | |   | -_|
|__|__|_|_|_  |_|_|_|_|___|
          |___|            

Anyline Flutter Plugin #

Anyline is 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.

This plugin is still in development, it is currently functional for Android only! #

Requirements: #

iOS #

not supported yet

Android #

minSDK >= 19

Example #

Take a look into example/lib/main.dart to see the implementation.

Quick Start Guide #

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 react-native plugin #

Via pub.dev:

Coming soon!

Follow the instructions given on using unpublished packages and add the following lines to your pubspec.yaml:

dependencies:
  anyline-ocr-flutter-module:
    git:
      url: git://github.com/Anyline/anyline-ocr-flutter-module.git

3. Import the plugin into your Dart file #

import 'package:anyline-ocr-flutter-module/anyline_plugin.dart';

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

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

Add and import 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 about the result structure, check out the platform-specific documentation for Android and iOS.

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

To be implemented

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.