| MIL 10 Reference
| Customize Help
| Save Settings

McodeRead



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
Read the code(s) in an image as specified in the code context.
Syntax
void McodeRead(
MIL_ID ContextCodeId, //in
MIL_ID ImageBufId, //in
MIL_ID ResultCodeId //in
)
Description

This function searches for the code(s) in an image, as specified in the code context, and writes the results in the designated result buffer. The code context's control settings determine how to perform the operation. Retrieve results using McodeGetResult() or McodeGetResultSingle().

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

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_SCANLINE_INPUT_UNITS, M_DOT_SPACING_INPUT_UNITS, M_FINDER_PATTERN_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 McodeRead() a calibrated target image, the function will generate an error.

Before performing a read operation, certain controls might have to be set globally for the entire code context or individually for each code model in McodeControl(). When reading multiple occurrences of Data Matrix codes, setting one or more of these values and reducing the searching speed (using McodeControl() with M_SPEED) will produce more robust results.

Control

Notes

M_CELL_NUMBER_X, M_CELL_NUMBER_Y

For 2D code types only, improves the robustness of the operation.

M_CELL_SIZE_MIN, M_CELL_SIZE_MAX

To improve the robustness of read operations for some code types, especially Data Matrix and Maxicode.

Note that MIL might have difficulty reading codes if the cell size is less than 2 pixels, even if the size is specified.

M_ENCODING

For code types where M_ANY is not supported.

M_ERROR_CORRECTION

For code types where M_ANY is not supported.

M_FOREGROUND_VALUE

This control is essential for all code types, and the image will not be decoded if the foreground value is not correctly set.

M_SEARCH_ANGLE, M_SEARCH_ANGLE_DELTA_NEG, M_SEARCH_ANGLE_DELTA_POS

If the code to read is not within 5° of the horizontal axis, and/or if the code has bearer bars.

M_STRING_SIZE_MIN and M_STRING_SIZE_MAX

For the M_BC412 code type, the string size must be specified.

M_SUB_TYPE

For M_COMPOSITECODE and M_GS1_DATABAR code type, specifying the code sub-type can help increase the speed of read operations.

Note that if the image contains Structured Append sequence of separate but logically linked ECC 200 codes, MIL will treat the codes as separate, independent codes.

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.

ImageBufId

Specifies the 8-bit unsigned 1-band image buffer in which to search.

This image buffer can only 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 a non-rectangular shape.

ResultCodeId

Specifies the result buffer in which to write the results of the read.

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