TABLE OF CONTENTS


GENERAL PRODUCT DOCUMENTATION


CURRENT VERSION

2020.12 – released December 2020


SYSTEM REQUIREMENTS AND PRE-REQUISITES

  • The minimum version of Android SDK: 14


PERMISSIONS

  • Read/write from/to external storage
  • Internet (only for online activation of licenses)


PREPARATION FOR USAGE

Import library

  • Copy *.aar file to the folder 'libs' of your project
  • Add this line in the dependencies section
    • compile fileTree(include: ['*.jar'], dir: 'libs')
  • Add dependency on the file to build.gradle file of your project
    • compile (name:'licensed-ocr-engine-release', ext:'aar')
    • api 'commons-codec:commons-codec:1.10'


RECOGNIZE

  • Create an instance of the class MainInteractorImpl
  • Call the method recogFromBufferToJSON or recogFromFileToJSON
  • Pass the next arguments to the method
    • API Key
    • Licensed API Key
    • An array of paths to the photos (for recogFromFileToJSON) to be recognized or array of bytes (for recogFromBufferToJSON) from the image
    • Implementation of interface MainInteractor.Callback, that has the methods, described in Process results of recognizing.


PROCESS RESULTS OF RECOGNITION

There are two methods, that may be called during recognize process.

  • recogOk(Map<String, String> recognizedData)
    • recognizedData map has results. Each entry of the map consist of {key} – {path-to-file} and {value} – {result-of-recognizing}
  • recogError(BaseOcrException exception)

This method is called when an error has occurred in the license checking or recognizing process.

The parameter 'exception' can be an object of one of the following instances:

  • BlockedLicenseException: The license is blocked
  • InvalidApiKeyException: An invalid API key is used
  • InvalidLicenseException: The license is not valid
  • MissingLicenseException: This exception is thrown when a server key is imported, but there is no internet access to get the license. Catching this exception, a licensing request can be generated locally for license generation on the ConPDS licensing server.
  • NoServerKeyException: The server key is missing. It can happen at first launch of the app when the app tries to retrieve the server key. Catching this error server key importing should be done, as described in the section above.
  • NotApprovedException: The license is not approved yet.
  • NotSavedRequestException: An error has occurred when generating a license request.
  • ServiceNotAvailableException: The ConPDS licensing server is not available.
  • OtherException: All the other exceptions are being returned as an instance of the class. To get additional information about this exception the method getMessage is used on the object.

License checking errors

  • invalidServerPublicKey: Invalid server public key
  • invalidJSONResponse: Invalid JSON response
  • invalidResponse: Invalid response from server
  • invalidURL: Invalid server URL
  • invalidDevicId: Error while getting device ID
  • timeOut: Request timeout.
  • invalidAPIKey: Invalid API key


Example of usage

String licenseApiKey = "";

new MainInteractorImpl(this).recogFromFileToJSON (apiKey, licenseApiKey, new String[]{Environment.getExternalStorageDirectory()+"/containerNo_MNBU322426645R1.jpeg"}, new MainInteractor.Callback() {
@Override
public void recogOk(Map<String, String> map) {
System.out.println("OK: " + map.toString());
}
@Override
public void recogError(BaseOcrException e) {
System.out.println(e.getMessage());
}
});



String apiKey = "";
String licenseApiKey = "";
byte[] imageBytes = extractBytes(Environment.getExternalStorageDirectory()+"/containerNo_MNBU322426645R1.jpeg");

new MainInteractorImpl(this).recogFromBufferToJSON (apiKey, licenseApiKey, imageBytes, new MainInteractor.Callback() {
@Override
public void recogOk(Map<String, String> map) {
System.out.println("OK: " + map.toString());
}
@Override
public void recogError(BaseOcrException e) {
System.out.println(e.getMessage());
}
});


EXAMPLE PROJECTS (SOURCE CODE)