OCR SDK Knowledge Base

Article ID: 1555 | Category: Engine Initialization | Type: How To | Last Modified: 1/26/2017

How to initialize Engine in Android application?


Which values should be passed to dataSource and license parameters of the Engine.createInstance method call?


The dataSource is a list of DataSource objects. The program searches files with the data required for recognition (pattern, dictionary, keyword files, and so on) in the list. Usually and it is recommended to put patterns, dictionaries, keywords files etc. into the “assets” folder. More information about this moment you can find in the “Adding library to Java Project in Eclipse” article http://knowledgebase.ocrsdk.com/article/734.

The second parameter, “license” requires the link to the License object. This object containing the license information. You need to create FileLicense class object, by passing the same dataSource object, path to the license file and string containing the application identification (ApplicationID). The following code snippet will be helpful in this question:


private void startRecognition() {

final DataSource assetDataSrouce = new AssetDataSource(this.getAssets());

final List<DataSource> dataSources = new ArrayList<DataSource>();



try {

final FileLicense fileLicense = new FileLicense(assetDataSrouce, LICENSE_FILE, APPLICATION_ID);

final DataFilesExtensions dataFilesExtensions = new DataFilesExtensions(




Engine.createInstance(dataSources, fileLicense, dataFilesExtensions);

} catch(final IOException e) {


} catch(final License.BadLicenseException e) {




289 people think this is helpful.
Was this information helpful to you?