| MIL 10 Reference
| Customize Help
| Save Settings

McodeGrade



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Grades the code(s) in an image as specified in the code context.
Syntax
void McodeGrade(
MIL_ID ContextCodeId, //in
MIL_ID ImageBufId, //in
MIL_ID SrcResultCodeId, //in
MIL_INT SrcModelCodeIndexOrResultIndex, //in
MIL_ID DstResultCodeId, //in
MIL_INT64 ControlFlag //in
)
Description

This function computes the different quality-grades of the codes in an image, as specified in the code context, and writes the results in the destination result buffer. The code context's control settings determine how to perform the operation. Retrieve results using McodeGetResult() or McodeGetResultSingle().

Note that this function is not supported for 4-state, Pharmacode, Postnet, and Planet 1D code types or Aztec 2D code types with an encoding of Aztec Rune.

Since the global context settings are required to perform a grading operation, McodeGrade() requires that you pass a code context identifier, and not a code model identifier, as a parameter. The code context passed to McodeGrade() can contain multiple code models; the target image can contain one or more occurrences of the code models.

You can grade a single code or multiple codes with each call to this function, depending upon your requirements. In addition, by default this function performs a read operation before performing the grading operation. However, to speed up the process, you can perform the read operation using McodeRead() and pass the code result read to this function. Note that this functionality is not supported with Aztec code types. If the code result buffer contains the results of several codes read (code occurrences), specify the code occurrence (the result index) to grade a single code. If no code read result buffer is specified, and the code context contains multiple code models, you can specify the index of the model to grade or grade all the occurrences of all the models by default.

If a source code result buffer is not specified, the grading operation performs a read before grading the code. The results of the grading operation are written to the destination code result buffer, and the source code result buffer remains unchanged.

Before performing a grading operation, the following control types might have to be set globally for the entire code context or individually for each code model, using McodeControl().

Control type

Notes

M_FOREGROUND_VALUE

Specifies the foreground color of the code. This control type must be set if the foreground color is not black; the code will not be graded if the foreground value is not correctly set.

M_ENCODING

Specifies the type of encoding scheme for the code. This control type must be set if the default encoding scheme for your code's type differs from the one used by your code or if M_ANY is not supported.

M_ERROR_CORRECTION

Specifies the type of error correction for the code. This control type must be set if the default error correction scheme for your code's type differs from the one used by your code or if M_ANY is not supported.

M_STRING_SIZE....

Specifies the maximum and minimum size of the string (number of characters) encoded in each code. These control types must be set if M_STRING_SIZE_MIN and/or M_STRING_SIZE_MAX cannot be set to M_ANY.

M_SEARCH_ANGLE....

Specifies the nominal search angle and angular search range. These control types must be set if the code is at an angle greater or less than 0.0 ±5 degrees.

For more information on code model and code context settings that can improve McodeGrade() results, see the Customizing read and grading operation settings section of Chapter 12: Codes.

If you have associated the target image with a calibration context, you can specify that certain input settings be interpreted in world units. To do so, use McodeControl() with M_ABSOLUTE_APERTURE_SIZE_INPUT_UNITS, M_SCANLINE_INPUT_UNITS, M_DOT_SPACING_INPUT_UNITS, M_SEARCH_ANGLE_INPUT_UNITS, and/or M_CELL_SIZE_INPUT_UNITS set to M_WORLD. Note that if you set any of these constants to M_WORLD but you don't pass McodeGrade() a calibrated target image, the function will generate an error. Note that whatever settings you have made to read the code context previously should not be changed between performing an McodeRead() and an McodeGrade() operation. A source code result buffer (passed to this function) should contain results obtained from a calibrated target image for best results.

It is strongly recommended to use a region of interest (ROI), set using MbufSetRegion(), with grading operations, especially if your image contains more codes than your context is configured to grade; otherwise, MIL will randomly select the specified number of codes to grade. Grading only a portion of your image is also recommended because it achieves a fast and robust grade operation if your image contains other information besides the codes. Note that, if your image has an ROI, you can have the nominal angle set to the same angle as that of the image's ROI, using McodeControl() with M_SEARCH_ANGLE set to M_ACCORDING_TO_REGION.

You should note that if the code cannot be decoded by MIL, all grades will be returned as F.

If you cannot read a bar code with a cell size that is size 2 or smaller, you can enlarge the image using MimResize() and try again.

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 if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
ContextCodeId

Specifies the identifier of the code context, allocated using McodeAlloc().

ImageBufId

Specifies the identifier of the image buffer containing the code(s) to be graded. The image buffer must be an 8-bit, unsigned, 1-band image buffer. Note that, this image buffer should contain the same image used for the previous read operation.

This image buffer can have a rectangular region of interest (ROI), defined using MbufSetRegion() (with or without rotation). In addition, the region must be defined in vector format from a graphics list (M_VECTOR or M_VECTOR_AND_RASTER). An error will be generated if the ROI is only in raster format (M_RASTER) or is non-rectangular in shape.

SrcResultCodeId

Specifies a source code result buffer from which to retrieve read operation results. This parameter can be set to M_NULL.

If provided, the source code result buffer must contain results of a McodeRead() operation performed on the same source image. It must have previously been allocated using McodeAllocResult(). If no code result buffer is provided, McodeGrade() performs an internal read operation, resulting in slightly slower results.

If using an Aztec code type, this parameter can only be set to M_NULL.

SrcModelCodeIndexOrResultIndex

Specifies the index of the code model (in the code context) or the result occurrence (in the source result buffer) to use when grading the code. This parameter can be set to M_NULL.

The index of the code model is determined by the order in which it was added to the code context.

function map For specifying the model or the result containing information about the code to grade
CollapseValue Description
Collapse M_DEFAULT

Same as M_ALL.

Collapse M_NULL

Specifies that an index is not required.

Collapse M_ALL

Specifies to grade all occurrences of all code models in the code context or all occurrences of code models in the source result buffer.

Collapse Value >= 0

Specifies which code model (from the code context) or result index (from the result buffer) to use, when grading the code.

DstResultCodeId

Specifies the result buffer in which to write the resulting grading information. Allocate the result buffer using McodeAllocResult().

ControlFlag

Reserved for future expansion. This parameter must be set to M_DEFAULT.

Compilation information
Header Include mil.h.
Library Use mil.lib; milcode.lib.
DLL Requires mil.dll; milcode.dll.
UNSIGNED PROC RASTER DEFAULT NULL ALL