MIL_ID ContextCodeId, | //in |
MIL_ID ImageBufId, | //in |
MIL_ID ResultCodeId | //in |
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 |
For 2D code types only, improves the robustness of the operation. |
|
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. |
|
For code types where M_ANY is not supported. |
|
For code types where M_ANY is not supported. |
|
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. |
For the M_BC412 code type, the string size must be specified. |
|
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.
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.
Header | Include mil.h. |
Library | Use mil.lib; milcode.lib. |
DLL | Requires mil.dll; milcode.dll. |