| Customize Help
| Save Settings

McodeDetect



Function Map
Synopsis
Detect 1D code occurrences in an image.
Syntax
void McodeDetect(
MIL_ID ImageBufId, //in
MIL_INT SizeOfCodeTypeArray, //in
const MIL_INT *CodeTypeArrayPtr, //in
MIL_INT NumCodesToDetect, //in
MIL_INT64 TimeoutValue, //in
MIL_INT64 ControlFlag, //in
MIL_ID DetectResultCodeId //in
)
Description

This function detects code occurrences of most 1D code types in a specified image. It detects their code type and encoding scheme; it also establishes their position with high accuracy. You can automatically add a code model for each detected code type to a code context, using McodeModel() with M_RESET_FROM_DETECTED_RESULTS. Alternatively, you can use the detected code type and encoding scheme information to manually set up your code models with an appropriate code type and encoding scheme for the code occurrences in your images.

You can retrieve results using McodeGetResult(). Retrieve the code type and encoding scheme with M_CODE_TYPE and M_ENCODING, respectively. Prior to retrieving other results, you should ensure that McodeDetect() was successful by verifying that M_STATUS returns M_STATUS_DETECT_OK.

Some code types are a subset of another. If a code occurrence has only the common features of these code types, McodeDetect() cannot distinguish if the code occurrence is of one type or the other at decode-time. In these cases, McodeDetect() reports the following:

When the following code types cannot be differentiated

Code type reported

M_UPC_A and M_EAN13

M_UPC_A

M_EAN14, M_GS1_128, and M_CODE128

M_EAN14

M_GS1_128 and M_CODE128

M_GS1_128

You can remove this ambiguity by restricting the possible code types with CodeTypeArrayPtr. Another reason to restrict the possible code types is if you are not interested in detecting certain code types; this will accelerate the McodeDetect() operation.

Note that this function does not detect postal, GS1 Databar, Pharmacode, 2D, or composite code types. For the list of code types supported by McodeDetect(), use McodeInquire() with M_SUPPORTED_CODE_TYPES_DETECT.

This function tries to detect the specified number of code occurrences. If it detects more than the specified number of code occurrences in the specified image, the function only stores the results of those with the best quality. If it detects less than the specified number, McodeGetResult() with M_STATUS returns M_STATUS_DETECT_FAILED.

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
ImageBufId

Specifies the identifier of an image buffer that contains the code occurrences to detect. The image buffer must be an 8-bit unsigned 1-band buffer.

This image buffer can only have a rectangular region of interest (ROI) defined using MbufSetRegion() (with or without rotation). The region must be defined in vector format from a 2D 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.

SizeOfCodeTypeArray

Specifies the size of the array passed to CodeTypeArrayPtr.

When using a standard vector (std::vector) overload function in C++, you can pass M_DEFAULT to this parameter and MIL will automatically determine the size based on the number of items in the vector passed to the CodeTypeArrayPtr parameter.

function map For specifying the size of the code type array
Click to summarizeValue Description
Click to summarize M_DEFAULT

Specifies the default value; the default value is 0.

Click to summarize Value = 0

Specifies that an array is not passed to CodeTypeArrayPtr. McodeDetect() will search for all code types supported by it.

This value is only applicable when CodeTypeArrayPtr is set to M_NULL.

(summarize)
Click to summarize Value > 0

Specifies the size of the array.

CodeTypeArrayPtr
Accepts the address of one of the following:
  • array of type MIL_INT [optionally, in C++: a reference to a constant std::vector<MIL_INT> ] (and a maximum array rank for C# of 1)
    Required array size:(SizeOfCodeTypeArray)

Specifies the address of an array listing the possible code types to detect in the image. Instead of passing an array with M_SUPPORTED_CODE_TYPES_DETECT, you can set this parameter to M_NULL and set SizeOfCodeTypeArray to 0.

If an array is passed to CodeTypeArrayPtr, it can contain one or more of the following values to specify which code types to look for:

function map For specifying the code types to detect
Click to summarizeValue Description
Click to summarize M_BC412

Specifies a BC412 code type.

Click to summarize M_CODABAR

Specifies a Codabar code type.

Click to summarize M_CODE39

Specifies a Code 39 code type.

Click to summarize M_CODE93

Specifies a Code 93 code type.

Click to summarize M_CODE128

Specifies a Code 128 code type.

Click to summarize M_EAN8

Specifies an EAN 8 code type.

Click to summarize M_EAN13

Specifies an EAN 13 code type.

Click to summarize M_EAN14

Specifies an EAN 14 code type.

Click to summarize M_GS1_128

Specifies a GS1-128 code type.

Click to summarize M_INDUSTRIAL25

Specifies an Industrial 2 of 5 (standard 2 of 5) code type.

Click to summarize M_INTERLEAVED25

Specifies an Interleaved 2 of 5 (ITF-14) code type. INFO

Click to summarize M_SUPPORTED_CODE_TYPES_DETECT

Specifies all 1D code types supported by this function.

Click to summarize M_UPC_A

Specifies a UPC-A code type.

Click to summarize M_UPC_E

Specifies a UPC-E code type.

NumCodesToDetect

Specifies the total number of code occurrences to detect in the image, regardless of their code type.

function map For specifying the number of code occurrences to detect
Click to summarizeValue Description
Click to summarize M_DEFAULT

Specifies the default value; the default value is 1.

Click to summarize Value >= 1

Specifies the number of code occurrences to detect.

TimeoutValue

Specifies the timeout period, in msec.

ControlFlag

Reserved for future expansion and must be set to M_DEFAULT.

DetectResultCodeId

Specifies the code detect result buffer in which to write the results. The result buffer must have been allocated using McodeAllocResult() with M_CODE_DETECT_RESULT.

Compilation information
Header Include mil.h.
Library Use mil.lib; milcode.lib.
DLL Requires mil.dll; milcode.dll.
UNSIGNED PROC RASTER DEFAULT BC412 CODABAR CODE39 CODE93 CODE128 EAN8 EAN13 EAN14 GS1 128 INDUSTRIAL25 INTERLEAVED25 SUPPORTED CODE TYPES DETECT UPC A UPC E DEFAULT