To retrieve results for all code model occurrences, use McodeGetResult() with the result type for the result that you want returned. To retrieve a result for a specific code model occurrence, use McodeGetResultSingle().
To retrieve the success of a read or grading operation, use M_STATUS. A positive status is returned only when all conditions, set for all the code models, are met. Note that when reading multiple code occurrences and more than one read operation fails, the error returned is the one you should probably fix first. For example, if you try to read two codes and one fails because the code was not found (M_STATUS_NOT_FOUND) and the other fails because the encoding type was unknown (M_STATUS_ENC_UNKNOWN), the latter is returned.
Every occurrence of every code model is associated with a unique index within the result buffer after a successful read or grading operation. When using McodeGetResultSingle(), you must specify the index of the occurrence for which to retrieve results.
The following table presents an example of a code result buffer, showing the result occurrence index, model index, angle, and string for 6 occurrences of 4 models in a context. If, for instance, you wanted to get additional results about only one of these occurrences, you should pass the result occurrence index to McodeGetResultSingle() along with the required result type. Results are ordered in the sequence that they are found.
Result type |
Result occurrence index |
|||||
0 |
1 |
2 |
3 |
4 |
5 |
|
3 |
3 |
1 |
0 |
2 |
0 |
|
9.0 |
7.0 |
2.0 |
4.0 |
0.0 |
0.0 |
|
First occurrence of code model 3 |
Second occurrence of code model 3 |
Only occurrence of code model 1 |
First occurrence of code model 0 |
Only occurrence of code model 2 |
Second occurrence of code model 0 |
The result occurrence index is not explicitly returned by any function in the MIL Code module, instead it must be deduced from the order in which the results are returned by McodeGetResult(); results are always indexed in ascending order starting from zero. To retrieve the number of occurrences in a code context, use McodeGetResult() with M_NUMBER.
For each code occurrence read, you can retrieve the decoded string or the length of the string, using M_STRING or M_STRING_SIZE, respectively. Combining M_ESCAPE_SEQUENCE with M_STRING will return the string with unprintable characters represented by their ASCII code (in hexadecimal notation, prefixed by \x). Combining M_ESCAPE_SEQUENCE with M_STRING_SIZE will return the length of the decoded string with the ASCII characters used to represent unprintable characters included in the count.
The McodeDraw() function provides several operations for drawing results in any specified image buffer or graphics list. By drawing into the display's overlay buffer or associating the graphics list with the display, you can also annotate an image non-destructively (see the Annotating the displayed image non-destructively section of Chapter 21: Displaying an image).
You can use a previously allocated graphics context (see Chapter 22: Generating graphics) to control the drawing color, or use the default graphics context (M_DEFAULT).
Supported drawing operations include drawing the bounding box of the specified code occurrence (using M_DRAW_BOX) or a cross-like symbol at the mid-point of the code occurrence (using M_DRAW_POSITION). McodeDraw() can draw the code with its quiet zone (using M_DRAW_QUIET_ZONE) and (optionally) the extended area (using M_DRAW_EXTENDED_AREA). McodeDraw() can draw the scan path (using M_DRAW_SCAN_PROFILES) or the scan reflectance profiles of the code (M_DRAW_REFLECTANCE_PROFILE), as analyzed by the grading operation. The scan reflectance profile is generated from sampling the code along a single scan path using a specific aperture. The following is an example of a scan reflectance profile of the code.
Unless otherwise specified, all scan paths will be drawn. To draw the path of a specific scan reflectance profile, specify the index of the scan reflectance profile using the ResultIndex parameter of McodeDraw(). The following is an example of 10 scan paths drawn over the existing image of the code.
When drawing composite codes, you can draw either the 2D (M_2D_COMPONENT) or the 1D (M_LINEAR_COMPONENT) component of the code.