Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

The example shown below describes an OCR configuration. Custom .any- and .ale files can be implemented for other use cases as well. In this case please use the corresponding Anyline Config classes.

  1. Copy the the .ale file to the folder app/src/main/assets of your app.

  2. Check if there is a folder app/src/main/trained_models. If it does not exist, create this folder.

  3. Copy the .any file to the newly created folder app/src/main/trained_models.

  4. Add the following statements to your Android activity:

    Code Block
    ...
    private ScanView scanView;
    private OcrScanViewPlugin scanViewPlugin;
    io.anyline.plugin.ocr.AnylineOcrConfig anylineOcrConfig;
    ...
    
    scanView = findViewById(R.id.scan_view);
    ...
    // this is one way to set the view configuration file:
    try {
        scanView.init("your_view_configuration_file.json");
    } catch (Exception e) {
        e.printStackTrace();
    }    
    ...
    anylineOcrConfig = new AnylineOcrConfig();
    ...
    anylineOcrConfig.setCustomCmdFile("your_custom_file.ale");
    anylineOcrConfig.setModel("your_custom_file.any");
    // add further config settings
    ...
    scanViewPlugin = new OcrScanViewPlugin(getApplicationContext(), 
            anylineOcrConfig, scanView.getScanViewPluginConfig(), "OCR");
    ...  
    scanView.setScanViewPlugin(scanViewPlugin);