MdlocrAlloc
| Board | Supported |
|---|---|
| Host System | Yes |
| V4L2 | Yes |
| Clarity UHD | Yes |
| Concord PoE | No |
| GenTL | Yes |
| GevIQ | Yes |
| GigE Vision | Yes |
| Indio | No |
| Iris GTX | Yes |
| Radient eV-CL | Yes |
| Rapixo CL | Yes |
| Rapixo CoF | Yes |
| Rapixo CXP | Yes |
| USB3 Vision | Yes |
Allocate a Deep Learning OCR context.
Syntax
AIL_ID MdlocrAlloc(
AIL_ID SysId, //in
AIL_INT64 ContextType, //in
AIL_INT64 ControlFlag, //in
AIL_ID * ContextDlocrIdPtr //out
)
Description
This function allocates a Deep Learning OCR read context, or a Deep Learning OCR fine-tuning context on the specified system. A Deep Learning OCR read context contains information required to perform an MdlocrRead operation, which allows you to read strings of text without defining a font. A Deep Learning OCR fine-tuning context is used to perform an MdlocrFinetune operation on a Deep Learning OCR read context with a dataset, allocated using MdlocrAllocDataset. This allows you to train a predefined read context on images from your use-case.
By default, a Deep Learning OCR read context is set to read all text in an image within the default character height bounds. If you want to restrict the string that is found and read, add a string model; string models are optional. MdlocrDefineModelFromResult allows you to define the string model so that attributes are automatically set from a resulting string found using MdlocrRead. If you only want to restrict the number of characters in the string, you can use MdlocrDefineModel. Regardless of how you add a model, you can always constrain the characters that appear at certain positions using MdlocrControlConstraint and adjust general string model settings, such as, character height and number of characters using MdlocrControlStringModel.
A Deep Learning OCR context internally handles characters in Unicode.
When allocating the read context, you should specify whether to use an algorithm that favors robustness or speed should be used, depending on the complexity of your images and your processing power restrictions.
Global settings and string model-specific settings and positional constraints are all held in a Deep Learning OCR read context; use MdlocrControl, MdlocrControlConstraint, and MdlocrControlStringModel to set these up, respectively.
When the Deep Learning OCR context is no longer required, release it usingMdlocrFreeunless M_UNIQUE_ID was specified during allocation; if M_UNIQUE_ID was specified, the smart identifier manages the Deep Learning OCR context's lifetime and you must not manually free it.
Parameters
SysId (in, AIL_ID)
Specifies the identifier of the system on which to allocate the Deep Learning OCR context. Set this parameter to one of the values below:
For specifying the system identifier
| Value | Description |
|---|---|
M_DEFAULT_HOST | Specifies the default Host system of the current Aurora Imaging Library application. |
System identifier | Specifies a valid system identifier, previously allocated using MsysAlloc. |
ContextType (in, AIL_INT64)
Specifies the type of context to allocate. Set this parameter to the value below:
For specifying the type of read context to allocate
| Value | Description |
|---|---|
M_OCR_NET1_BALANCED_V1 | Specifies to allocate a Deep Learning OCR read context with a balanced deep learning model based on the NET1 architecture. The performance and accuracy of this context falls between M_OCR_NET1_FAST_V1 and M_OCR_NET1_EXTENDED_V1. This context should be used on average complexity images and when processing power restrictions are not too high. |
M_OCR_NET1_EXTENDED_V1 | Specifies to allocate a Deep Learning OCR read context with the most robust deep learning model based on the NET1 architecture. Maximum accuracy over M_OCR_NET1_FAST_V1 and M_OCR_NET1_BALANCED_V1 comes at the cost of speed. This context should be used on high complexity images when processing power restrictions are low. |
M_OCR_NET1_FAST_V1 | Specifies to allocate a Deep Learning OCR read context with the fastest deep learning model based on the NET1 architecture. Faster performance over M_OCR_NET1_EXTENDED_V1 and M_OCR_NET1_BALANCED_V1 comes at the cost of lower accuracy. This context should be used on simpler images and when processing power is limited. |
M_OCR_NET2_TINY_V1 | Specifies to allocate a Deep Learning OCR read context with the tiny deep learning model based on the NET2 architecture. This context can be fine-tuned, using MdlocrFinetune with a Deep Learning OCR dataset (M_OCR_NET2_DATASET) and a Deep Learning OCR fine-tuning context (M_OCR_NET2_FINETUNE_CONTEXT). |
For specifying the type of fine-tuning context to allocate
| Value | Description |
|---|---|
M_OCR_NET2_FINETUNE_CONTEXT | Specifies to allocate a Deep Learning OCR fine-tuning context. This can be used with Deep Learning OCR read contexts based on the NET2 architecture (M_OCR_NET2_TINY_V1). |
ControlFlag (in, AIL_INT64)
Reserved for future expansion and must be set to M_DEFAULT.
ContextDlocrIdPtr *(out, AIL_ID)
Specifies the address of the variable in which to write the Deep Learning OCR context identifier or specifies the data type that the function should use to return the Deep Learning OCR context identifier.
For retrieving the identifier or specifying how to return it
| Value | Description |
|---|---|
M_NULL | Specifies that you will use this function's return value to obtain the identifier of the allocated Deep Learning OCR |
context; in this case, a standard Aurora Imaging Library identifier of type _AIL_ID_ is returned. |
| M_UNIQUE_ID | Specifies that you will use this function's return value to obtain the identifier of the allocated Deep Learning OCR
context; in this case, an Aurora Imaging Library smart identifier of type _AIL_UNIQUE_DLOCR_ID_is returned instead of a standard Aurora Imaging Library identifier.This setting is only available when using C++11 (or later).An Aurora Imaging Library smart identifier manages the lifespan of the Aurora Imaging Library object it owns (similar to a std::unique_ptr). Note, you can use an Aurora Imaging Library smart identifier as though it were a standard Aurora Imaging Library identifier, except that you cannot use it to manually free the Deep Learning OCR
context (it is freed automatically). For more information, see Aurora Imaging Library smart identifiers. |
| Address in which to write the fine-tuning identifier | Specifies the address of an AIL_ID in which to write the identifier of the allocated Deep Learning OCR fine-tuning context.
If allocation fails, M_NULL is written as the identifier. |
| Address in which to write the read context identifier | Specifies the address of an AIL_ID in which to write the identifier of the allocated Deep Learning OCR read context.
If allocation fails, M_NULL is written as the identifier. |
Return Value
Type: AIL_ID
The returned value is the Deep Learning OCR context identifier either as a standard identifier (AIL_ID) or a smart identifier (AIL_UNIQUE_DLOCR_ID). If allocation fails, M_NULL is returned (or nullptr ifM_UNIQUE_ID was specified).