Skip to main content

MdlocrDefineModel

BoardSupported
Host SystemYes
V4L2Yes
Clarity UHDYes
Concord PoENo
GenTLYes
GevIQYes
GigE VisionYes
IndioNo
Iris GTXYes
Radient eV-CLYes
Rapixo CLYes
Rapixo CoFYes
Rapixo CXPYes
USB3 VisionYes

Add a string model to, or delete a string model from, a Deep Learning OCR context.

Syntax

void MdlocrDefineModel(
AIL_ID ContextDlocrId, //in
AIL_INT64 StringModelLabelOrIndex, //in
AIL_INT64 Operation, //in
AIL_INT64 StringSizeMin, //in
AIL_INT64 StringSizeMax //in
)

Description

This function allows you to add a string model to, or delete a string model from, a Deep Learning OCR context.

You don't need to add a model to read all strings in the target image. In addition, if you want to restrict the string that is found and read, you should typically use MdlocrDefineModelFromResult, which allows you to select a resulting string as the model. MdlocrDefineModel is useful if you only want to restrict the number of characters in the string. 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, setting text anchors, using MdlocrControlStringModel.

Note that although you need to define the minimum and maximum number of characters of the string model when you add a new model with this function, you can change these limits using MdlocrControlStringModel with M_STRING_SIZE_MIN and M_STRING_SIZE_MAX.

Parameters

ContextDlocrId (in, AIL_ID)

Specifies the identifier of the Deep Learning OCR context in which to add or delete a model. The Deep Learning OCR context must have been previously allocated on the required system using MdlocrAlloc.

StringModelLabelOrIndex (in, AIL_INT64)

Specifies the string model (one or all) to control.

Operation (in, AIL_INT64)

Specifies whether to add or delete a string model from a Deep Learning OCR context.

StringSizeMin (in, AIL_INT64)

Specifies the minimum number of characters of a new string model. If the Operation parameter is set to M_DELETE, StringSizeMin must be set to M_DEFAULT.

For specifying the minimum number of characters

ValueDescription
M_DEFAULTSpecifies that this parameter is not needed (that is, when Operation set to M_DELETE).
Value >= 0Specifies the minimum number of characters.

StringSizeMax (in, AIL_INT64)

Specifies the maximum length of a new string model. If the Operation parameter is set to M_DELETE, StringSizeMax must be set to M_DEFAULT.

For specifying the maximum number of characters

ValueDescription
M_DEFAULTSpecifies that this parameter is not needed (that is, when Operation set to M_DELETE).
Value >= 0Specifies the maximum number of characters.

Parameter Associations

For creating or deleting a string model


M_ADD

Specifies to add a new string model to the context.

ValueDescription
M_DEFAULT
M_STRING_LABELSpecifies to add a string model with the specified label.
M_NEW_LABEL (default)Specifies to add a string model with an automatically assigned label. To inquire about the label, use MdlocrInquireStringModel with M_STRING_LABEL_VALUE.

M_DELETE

Specifies to delete a string model from a Deep Learning OCR context.

ValueDescription
M_DEFAULT
M_STRING_INDEXSpecifies to delete the string model by indicating its index.
M_STRING_LABELSpecifies to delete the string model by indicating its label.
M_ALL (default)Specifies to delete all string models from the Deep Learning OCR context.

Return Value

Type: void

Reserved for future expansion and returns M_NULL.

Copyright © 2026 Zebra Technologies.