This page shows you how to instantiate the iink runtime and configure it to fit your needs.
The iink SDK runtime is represented by an IINKEngine
object.
This object will let you create other key objects, configure the recognition and fine-tune the SDK behavior.
Here is how to instantiate it:
let data = Data(bytes: myCertificate.bytes, count: myCertificate.length)
guard let engine = IINKEngine(certificate: data) else {
self.engineErrorMessage = "Invalid certificate"
return nil
}
A new engine must be configured to let iink SDK know which kind of content is to be recognized.
Being a flexible toolkit, iink SDK also comes with many configuration parameters. While the default values make sense in most cases, it may sometimes be required to configure them to suit your needs.
The configuration can be obtained via the configuration
property of the IINKEngine
object.
It is possible to attach a delegate implementing the IINKConfigurationDelegate
protocol to a given configuration object to get notified when configuration
changes are made.
To recognize math, diagrams or text in any language, the engine needs to be created and pointed to the required assets.
Assets packages consist in a set of configuration files (*.conf
) that specify required recognition parameters combined to binary files called resources files (*.res
).
The resources files host everything that the engine requires for the recognition.
MyScript iink SDK default configurations should be suitable for most needs. So in most cases, you don’t have to care for them. If you need to go further, you can learn how to modify or write your own configuration files (advanced).
Default language for text recognition is en_US english. So one of the first recognition tuning you might want to do is modifying the language.
MyScript delivers some ready to use language packs so that updating language is an easy task that you can perform in a few steps:
Step 1 Download the corresponding language pack, so in our example, select the italian language: Packs for additional languages or content types are available on MyScript Developer Portal.
Step 2 Install the pack in your application project:
The language pack consists in a *.zip
archive containing a configuration file (*.conf
), and associated resources files (*.res
) to be extracted in your project path.
Step 3 Modifiy the engine configuration language in you application code:
configuration-manager.search-path
key to the folder(s) containing your language configuration file(s) (*.conf).lang
key to match your languageFor instance, set it_IT
for the Italian language, as corresponding resources are described in it_IT.conf
:
var configuration = engine.configuration;
let configurationPath = Bundle.main.bundlePath.appending("/recognition-assets/conf")
// Tells the engine where to load the recognition assets from.
configuration.set(stringArray: [configurationPath], forKey: "configuration-manager.search-path")
configuration.set(string: "it_IT", forKey: "lang")
MyScript iink SDK comes with many configuration options. Some are general, like the ability to choose the location of the temporary folder to store work data on the file system, and some depend on the type of content you manipulate. For instance, it is possible to activate or deactivate the solver for math equations.
The full list of supported configuration options can be found in the dedicated section.
Engine-level configuration corresponds to the default, global configuration. It is possible to override configuration values at editor-level, which is useful if you manage several parts with different configurations.
MyScript iink SDK configuration is an IINKParameterSet
object.
It can be seen as a set of key/value pairs, where values themselves can be other IINKParameterSet
objects.
You can read the value attached to an existing key, add new (key, value) pairs or remove existing ones.
Supported value types are strings, numbers, booleans, arrays of strings, as well as other IINKParameterSet
objects.
Here is a representation of such a structure:
{
"name": "iink SDK",
"interactive": true,
"version":
{
"major": 1,
"minor": 0
},
"parts": [ "Text", "Math", "Diagram", "Drawing", "Raw Content", "Text Document"]
}
The code below shows how to manipulate this structure when stored in a parameters
variable:
// Access a section content
let version = configuration.section(forKey: "version")
// Read a value for a key
let major = configuration.number(forKey: "version.major", defaultValue: 2.1) // -> 2.1
// Set a value for a key
configuration.set(number: "version.major", value: major! + 2.1); // -> 2.1
The next step of this guide will show how to load and save content.