| MIL 10 Reference
| Customize Help
| Save Settings

MocrGetResult



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
Get the specified type of result(s) from an OCR result buffer.
Syntax
void MocrGetResult(
MIL_ID ResultOcrId, //in
MIL_INT64 ResultType, //in
void *ResultPtr //out
)
Description

This function retrieves the result(s) of the specified type from an OCR result buffer. The information can be retrieved as a text, a string or a character. A text contains one or more strings. A string contains one or more characters. Results are only available after calling MocrReadString() or MocrVerifyString().

If your target image was associated with a calibration context, positional and dimensional results are, by default, returned with respect to the relative coordinate system of the image. Otherwise, these results are returned in pixels, relative to the top-left pixel in the target image.

If your target image was associated with a calibration context but you want to retrieve positional and dimensional results in pixel units, use MocrControl() with the M_RESULT_OUTPUT_UNITS control type set to M_PIXEL. However, note that if you set M_RESULT_OUTPUT_UNITS to M_WORLD without specifying a calibrated image in which to calculate the results, MocrGetResult() will generate an error.

Note that, by default, the first string found is returned as a result. To get the result for a specific string or for all strings from a result buffer, use MocrControl() with M_SELECT_STRING.

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
ResultOcrId

Specifies the identifier of the OCR result buffer from which to retrieve results.

ResultType

Specifies the type of result(s) to retrieve. The following values are available to retrieve results from a read or a verify operation, unless otherwise specified.

See the Parameter associations section for possible values that can be specified.

ResultPtr
Accepts the address of one of the following (see the Parameter associations section for specifics on which is expected):
  • array of type MIL_DOUBLE
  • array of type MIL_TEXT_CHAR
  • char
  • MIL_DOUBLE
  • MIL_FLOAT
  • MIL_INT
  • MIL_INT16
  • MIL_INT32
  • MIL_INT64
  • MIL_TEXT_CHAR

Specifies the address in which to write the results. Each line of text found within the target image is read as a separate string. If there is only one line of text, there is only one string. Only the results from the first string or selected strings (MocrControl() with M_SELECT_STRING) are obtained.

See the Parameter associations section for possible values that can be returned.

The tables below list possible values for the ResultType parameter and possible values returned to the ResultPtr parameter.

To retrieve a result for all strings, the ResultType parameter can be set to one of the following:

Unless otherwise specified, the following values require that you pass the ResultPtr parameter the address of a MIL_DOUBLE.

function map For all strings
CollapseResultType Description
ResultPtr
- Possible values returned
Collapse M_TEXT +

Retrieves the entire text. This includes all available strings, their separators, and the terminating character. Note that the string separator can be controlled using MocrControl() with M_TEXT_STRING_SEPARATOR.

(summarize)
Collapse ResultPtr data type info

Data type: array of type MIL_TEXT_CHAR
Array size: M_TEXT_LENGTH

Collapse M_TEXT_LENGTH +

Retrieves the total number of characters in the entire text. This includes all available strings, their separators, and the terminating character. Note that the string separator can be controlled using MocrControl() with M_TEXT_STRING_SEPARATOR.

(summarize)
Collapse M_TEXT_SCORE +

Retrieves the match score for the entire text as determined during the read/verify operation.

(summarize)
Collapse M_THRESHOLD +

Retrieves the value used to binarize the target image. Note that this is available only when using an M_GENERAL OCR font context, or when using an M_CONSTRAINED OCR font context if your target image has multiple lines, or its string angle is not 0.0°.

(summarize)

The following values are available to retrieve results from a read or a verify operation, unless otherwise specified. To retrieve a result for a string or all strings, the ResultType parameter can be set to one of the following:

Unless otherwise specified, the following values require that you pass the ResultPtr parameter the address of a MIL_DOUBLE (for a single string) or the address of an array of type MIL_DOUBLE with a size equal to M_NB_STRING (for multiple strings).

function map For retrieving results from a read or verify operation
CollapseResultType Description
ResultPtr
- Possible values returned
Collapse M_NB_STRING +

Retrieves the number of strings read by MocrReadString().

If no strings are found, 0 is returned.

(summarize)
Collapse ResultPtr data type info

Data type: MIL_DOUBLE
Note: For a single string or multiple strings.

Collapse M_STRING +

Retrieves the null-terminated string found during the read/verify operation. By default, any unrecognized character in the string will be replaced by the most-likely character, even if the match score for that character is lower than the specified character acceptance level (MocrControl() with M_CHAR_ACCEPTANCE). You can replace all unrecognized characters in the string with an invalid character symbol by calling MocrControl() with M_CHAR_INVALID.

Note that no string separator is inserted between the different strings when getting all strings simultaneously. Refer to M_TEXT to retrieve the strings with separators.

(summarize)
Collapse ResultPtr data type info
  • Data type: array of type MIL_TEXT_CHAR
    Array size: M_STRING_SIZE +1
    Note: For a single string.

  • Data type: array of type MIL_TEXT_CHAR
    Array size: the sum of all string lengths +1 (M_STRING_SIZE + M_SUM)+1
    Note: For multiple strings.

Collapse M_STRING_ALLOC_SIZE +

Retrieves the total size of the string, including the terminating null character ("\0"). For multiple strings, the total size of each string, including its terminating null character ("\0"), is returned.

(summarize)
Collapse M_STRING_ANGLE +

Retrieves the search angle of the string, in degrees, relative to the output coordinate system specified using MocrControl() with M_RESULT_OUTPUT_UNITS. For multiple strings, the search angle of each string is returned. Note that all strings are searched for at the same angle, so all returned values will be equivalent.

An angle interpreted with respect to the pixel coordinate system is always measured counter-clockwise. For information on the angle's direction of rotation when interpreting the angle with respect to the relative coordinate system, see the Angle convention in MIL subsection of the Working with real-world units section of Chapter 25: Calibrating your camera setup.

(summarize)
Collapse M_STRING_SCORE +

Retrieves the score calculated during the read/verify operation for the entire string. For multiple strings, the calculated score for each string is returned.

(summarize)
Collapse M_STRING_SIZE +

Retrieves the length of the null-terminated string found during the read/verify operation, not including the terminating null character ("\0") itself. For multiple strings, the length of each null-terminated string, not including the terminating null character ("\0") itself, is returned.

(summarize)
Collapse M_STRING_VALID_FLAG +

Retrieves the result of the read/verify operation as a flag that denotes the validity of the string. The flag's validity status is determined by comparing the string's read score with the string's acceptance level (MocrControl() with M_STRING_ACCEPTANCE). For multiple strings, a validity flag for each string is returned.

(summarize)
Collapse M_FALSE

Specifies that the string's score is below the string acceptance level.

Collapse M_TRUE

Specifies that the string's score is above the string acceptance level.

Combination constant for M_STRING_SIZE.

You can add the following value to the above-mentioned value to get the total length of all available strings.

function map For M_STRING_SIZE
CollapseResultType Description
ResultPtr
- Possible values returned
Collapse M_SUM

Retrieves the total length of all available strings without the NULL terminating character or string separators.

(summarize)
Collapse ResultPtr data type info

Data type: MIL_DOUBLE
Note: For a single string or multiple strings.

To retrieve a result for individual characters, the ResultType parameter can be set to one of the following:

Unless otherwise specified, for a single string, the following values require that you pass the ResultPtr parameter the address of an array of type MIL_DOUBLE with a size equal to M_STRING_SIZE. For multiple strings, the following values require that you pass the ResultPtr parameter the address of an array of type MIL_DOUBLE with a size equal to M_STRING_SIZE + M_SUM.

function map For individual characters
CollapseResultType Description
ResultPtr
- Possible values returned
Collapse M_CHAR_POSITION_X +

Retrieves the X-position of each individual character in the string, or strings.

(summarize)
Collapse M_CHAR_POSITION_Y +

Retrieves the Y-position of each individual character in the string, or strings.

(summarize)
Collapse M_CHAR_SCORE +

Retrieves the match score of each individual character within the string, or strings.

(summarize)
Collapse M_CHAR_SIZE_X +

Retrieves the cell width of each character within the string, or strings.

(summarize)
Collapse M_CHAR_SIZE_Y +

Retrieves the cell height of each character within the string, or strings.

(summarize)
Collapse M_CHAR_SPACING +

Retrieves the spacing between each pair of characters in the selected string, or strings. Note that the spacing of the last character in each string is M_NULL.

(summarize)
Collapse M_CHAR_VALID_FLAG +

Retrieves the result of the read/verify operation as flags that denote the validity of each character within the string, or strings. Each flag's validity status is determined by comparing the character's read score with the character's acceptance level (MocrControl() with M_CHAR_ACCEPTANCE).

(summarize)
Collapse M_FALSE

Specifies that the character's score is below the character acceptance level.

Collapse M_TRUE

Specifies that the character's score is above the character acceptance level.

You can add one of the following values to the above-mentioned values to cast the requested results to a required data type.

function map For specifying the data type
CollapseResultType Description
ResultPtr
- Possible values returned
Collapse M_TYPE_CHAR

Casts the requested results to a char.

(summarize)
Collapse ResultPtr data type info

Data type: char

Collapse M_TYPE_MIL_DOUBLE

Casts the requested results to a MIL_DOUBLE.

(summarize)
Collapse ResultPtr data type info
  • Data type: array of type MIL_DOUBLE
    Array size: Depends on the result type.
    Note: When multiple results.

  • Data type: MIL_DOUBLE
    Note: When a single result.

Collapse M_TYPE_MIL_FLOAT

Casts the requested results to a MIL_FLOAT.

(summarize)
Collapse ResultPtr data type info

Data type: MIL_FLOAT

Collapse M_TYPE_MIL_INT

Casts the requested results to a MIL_INT.

(summarize)
Collapse ResultPtr data type info

Data type: MIL_INT

Collapse M_TYPE_MIL_INT16

Casts the requested results to a MIL_INT16.

(summarize)
Collapse ResultPtr data type info

Data type: MIL_INT16

Collapse M_TYPE_MIL_INT32

Casts the requested results to a MIL_INT32.

(summarize)
Collapse ResultPtr data type info

Data type: MIL_INT32

Collapse M_TYPE_MIL_INT64

Casts the requested results to a MIL_INT64.

(summarize)
Collapse ResultPtr data type info

Data type: MIL_INT64

Collapse M_TYPE_TEXT_CHAR

Cast the requested results to a MIL_TEXT_CHAR.

(summarize)
Collapse ResultPtr data type info
  • Data type: MIL_TEXT_CHAR
    Note: When a single result.

  • Data type: array of type MIL_TEXT_CHAR
    Array size: Size depends on the contents of the array
    Note: When multiple results.

Compilation information
Header Include mil.h.
Library Use mil.lib; milocr.lib.
DLL Requires mil.dll; milocr.dll.
TEXT TEXT LENGTH TEXT SCORE THRESHOLD NB STRING STRING STRING ALLOC SIZE STRING ANGLE STRING SCORE STRING SIZE STRING VALID FLAG FALSE TRUE SUM CHAR POSITION X CHAR POSITION Y CHAR SCORE CHAR SIZE X CHAR SIZE Y CHAR SPACING CHAR VALID FLAG FALSE TRUE TYPE CHAR TYPE MIL DOUBLE TYPE MIL FLOAT TYPE MIL INT TYPE MIL INT16 TYPE MIL INT32 TYPE MIL INT64 TYPE TEXT CHAR