| Customize Help
| Save Settings

McodeAlloc



Function Map
Synopsis
Allocate a code context.
Syntax
MIL_ID McodeAlloc(
MIL_ID SysId, //in
MIL_INT64 ContextType, //in
MIL_INT64 ControlFlag, //in
MIL_ID *ContextCodeIdPtr //out
)
Description

This function allocates a code context. A code context is a MIL object that stores one or more code models. The code model is used by the McodeRead(), McodeGrade(), McodeTrain(), and McodeWrite() operations.

To add code models to the context, use McodeModel(). A code context can contain multiple code models of 1D code types (excluding GS1 databar, Planet, Postnet, and 4-state); for other code types, a code context can contain at most one code model. To identify the types of code occurrences in an image, you can perform a McodeDetect() operation; note that a code context is not required for a McodeDetect() operation.

To adjust code model settings, use McodeControl().

When allocating a code context, specify whether the context should be initialized for a robust or a typical McodeRead(), McodeGrade(), or McodeTrain() operation. The initial configuration of the code context establishes the default values for some code context and code model settings. To change the initial configuration at a later date, use McodeControl() with M_INITIALIZATION_MODE. The explicit restrictions are indicated within the description of each code model setting; see McodeControl() for details.

To read and grade code occurrences in an image, use McodeRead() and McodeGrade(), respectively. The module only supports searching for multiple occurrences of 1D codes (excluding 4-State, GS1 Databar, Planet, and Postnet code types) and 2D Data Matrix codes. For other types of code occurrences, the module only supports searching for a single occurrence. When reading or grading multiple code occurrences, all results can be retrieved using McodeGetResult() with M_ALL. Each occurrence has a set of results.

To establish the best possible control type settings given your images, use McodeTrain().

When the code context is no longer needed, you should free it, using McodeFree().

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see which MIL system’s documentation you should use in its place and any possible differences.
Parameters
This function is not supported on the selected boards.
This function reference has not been updated for the selected MIL system. To show the content of this page, choose a second MIL system; refer to the MIL system's release note to see which MIL system’s documentation to choose and any possible differences.
Parameters
SysId INQ

Specifies the system on which to allocate the context. This parameter should be set to one of the following values:

function map For specifying the system
Click to summarizeValue Description
Click to summarize M_DEFAULT_HOST

Specifies the default Host system of the current MIL application.

Click to summarize MIL system identifier

Specifies a valid system identifier, previously allocated using MsysAlloc().

ContextType

Specifies the context type. Reserved for future expansion. This parameter must be set to M_DEFAULT.

ControlFlag

Specifies the initial configuration for the code context. The restrictions are indicated within each control, see McodeControl() for details.

function map For specifying the initial configuration of the code context
Click to summarizeValue Description
Click to summarize M_DEFAULT

Same as M_TYPICAL_RECOGNITION.

Click to summarize M_IMPROVED_RECOGNITION

Specifies a code context that might provide a more robust McodeRead(), McodeGrade(), or McodeTrain() operation. This initialization mode is recommended if your target images lack similarity (for example, some but not all include complex or noisy backgrounds), contain distorted code occurrences, or contain code occurrences that are at an angle or even flipped. It is also recommended when searching for 2D matrix codes that are composed of dots.

Note that when selecting this mode, the default of the affected code context and code model settings might change between MIL releases to improve robustness, given new features or standard recommendations.

This initialization mode is not recommended with M_PHARMACODE code types.

(summarize)
Click to summarize M_TYPICAL_RECOGNITION

Specifies a code context that might provide a quicker McodeRead() or McodeGrade() operation, but might potentially produce less robust results.

ContextCodeIdPtr

Specifies the address in which to return the identifier of the code context. Since this function also returns the identifier, this parameter can be set to M_NULL.

Return value
The returned value is the code context identifier if the allocation is successful. If allocation fails, M_NULL is returned.
Compilation information
Header Include mil.h.
Library Use mil.lib; milcode.lib.
DLL Requires mil.dll; milcode.dll.
DEFAULT HOST DEFAULT IMPROVED RECOGNITION TYPICAL RECOGNITION