Skip to main content

MocrSetConstraint

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

Set character position constraints.

Syntax

void MocrSetConstraint(
AIL_ID FontContextOcrId, //out
AIL_INT CharPos, //in
AIL_INT64 CharPosType, //in
AIL_CONST_TEXT_PTR CharValidString //in
)

Description

This function specifies which character value constraints to apply to each position of the strings in the target image, when using the specified OCR font context. This function specifies which characters can appear at given positions in the string to be read, and associates these constraints with the OCR font context. Using this function increases both speed and reliability as long as the strings in the target image have a known format and obey certain grammatical rules.

Note that constraints are set in regards to the character's position in the string. When dealing with multiple strings, the same constraints are applied to each string.

If you change any constraints, use MocrPreprocess to speed up any following read or verify operation.

Parameters

FontContextOcrId (out, AIL_ID)

Specifies the OCR font context identifier with which to associate the constraints.

CharPos (in, AIL_INT)

Specifies the character position in the string for which a constraint is being set. Valid values range from zero to the length of the string -1.

CharPosType (in, AIL_INT64)

Specifies the type of character that can appear at the specified string position.

For specifying the type of character that is accepted

ValueDescription
M_DEFAULT
M_ANY (default)Specifies that all characters present in the font are valid.
M_DIGITSpecifies that only characters "0" to "9" (ASCII codes 48 to 57) are valid.
M_LETTERSpecifies that only characters "A" to "Z" and "a" to "z" (ASCII codes 65 to 90 and 97 to 122) are valid.

For

ValueDescription
M_LOWERCASESpecifies that only characters "a" to "z" (ASCII codes 97 to 122) are valid.
M_UPPERCASESpecifies that only characters "A" to "Z" (ASCII codes 65 to 90) are valid.

CharValidString (in, AIL_CONST_TEXT_PTR)

Specifies that any character matching the given CharPosType will be accepted as valid, or explicitly lists valid characters for the specified position.

For specifying whether all characters matching the CharPosType will be accepted

ValueDescription
M_NULLSets all font characters matching the CharPosType parameter value as valid.
"StringOfCharacters"Specifies an explicit list of valid characters for the specified position. This string must be null-terminated. The accepted characters must match the CharPosType parameter definition and must exist in the font.
Copyright © 2026 Zebra Technologies.