| Customize Help
| Save Settings

MocrCalibrateFont



Function Map
Synopsis
Calibrate the OCR font context's character size and target spacing to match the characters in a sample target image.
Syntax
void MocrCalibrateFont(
MIL_ID ImageBufId, //in
MIL_ID FontContextOcrId, //in
MIL_CONST_TEXT_PTR String, //in
MIL_DOUBLE TargetCharSizeXMin, //in
MIL_DOUBLE TargetCharSizeXMax, //in
MIL_DOUBLE TargetCharSizeXStep, //in
MIL_DOUBLE TargetCharSizeYMin, //in
MIL_DOUBLE TargetCharSizeYMax, //in
MIL_DOUBLE TargetCharSizeYStep, //in
MIL_INT64 Operation //in
)
Description

This function automatically calibrates the X and Y size and spacing of the font of a specified OCR font context to match that of a string in the sample target image. Note that these values can also be set manually with MocrControl() with M_TARGET_CHAR_SPACING, M_TARGET_CHAR_SIZE_X, and M_TARGET_CHAR_SIZE_Y. This function can only calibrate an M_CONSTRAINED OCR font context. You can change the type of context using MocrControl() with M_CONTEXT_CONVERT.

The sample image must contain the string specified in the String parameter, and both the size and spacing must be representative of the images to be read or verified with the calibrated OCR font context. This function might not return the expected results if the sample image contains more or fewer characters than the specified target string length (MocrControl() with M_STRING_CHAR_NUMBER).

The better the sample image, the better the font calibration results. If a string cannot be located in the sample image, an error will be generated. Use MappGetError() to learn the error code and related information.

You can limit the operation to a region of the image buffer, using a rectangular region of interest (ROI) set using MbufSetRegion().

MocrCalibrateFont() should be called after defining a new OCR font context or when the character size in the target images changes.

The resulting target values are the best match between the minimum and the maximum target character sizes specified in the parameters of this function. Font calibration will increment the minimum target character size by a step value until it reaches the maximum target character size. You can inquire the target character sizes and spacing with MocrInquire(). For best results, use a range of +/- 1 pixel with, for example, a step of between 0.1 and 0.2 pixels. Note that the greater the number of steps between the minimum and the maximum target character sizes, the longer this operation will take.

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 the sample target image buffer. The characters of the string in this sample image must be of the same type and size as that in the images to be read or verified using the OCR font context.

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 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.

FontContextOcrId

Specifies the identifier of the OCR font context to be calibrated.

String

Specifies the character string present in the sample target image. This string must be null-terminated.

function map For specifying the character string
Click to summarizeValue Description
Click to summarize MIL_TEXT("String") 1

Specifies the character string that is present in the sample target image. This string must be null-terminated.

(summarize)

1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().

TargetCharSizeXMin

Specifies the minimum width of the characters in the sample target image, in pixels.

function map For specifying the minimum width of the characters
Click to summarizeValue Description
Click to summarize 6 <= Value <= 256

Sets the minimum width, in pixels. Note that the specified value must satisfy the following: ( TargetCharSizeXMin / CharSizeX ) >= 0.25.

(summarize)
TargetCharSizeXMax

Specifies the maximum width of the characters in the sample target image, in pixels.

function map For specifying the maximum width of the characters
Click to summarizeValue Description
Click to summarize 6 <= Value <= 256

Sets the maximum width, in pixels. Note that the specified value must satisfy the following: ( TargetCharSizeXMax / CharSizeX ) <= 4.0 .

(summarize)
TargetCharSizeXStep

Specifies the increment to use when searching for the character width between TargetCharSizeXMin and TargetCharSizeXMax. Note that very small step sizes should only be used within small ranges, otherwise application performance can be adversely affected.

TargetCharSizeYMin

Specifies the minimum height of the characters in the sample target image, in pixels.

function map For specifying the minimum height of the characters
Click to summarizeValue Description
Click to summarize 6 <= Value <= 256

Sets the minimum height, in pixels. Note that the specified value must satisfy the following: ( TargetCharSizeYMin / CharSizeY ) >= 0.25 .

(summarize)
TargetCharSizeYMax

Specifies the maximum height of the characters in the sample target image, in pixels.

function map For specifying the maximum height of the characters
Click to summarizeValue Description
Click to summarize 6 <= Value <= 256

Sets the maximum height, in pixels. Note that the specified value must satisfy the following: ( TargetCharSizeYMax / CharSizeY ) <= 4.0.

(summarize)
TargetCharSizeYStep

Specifies the increment to use when searching for the character height between TargetCharSizeYMin and TargetCharSizeYMax. Note that very small step sizes should only be used within small ranges, otherwise application performance can be adversely affected.

Operation

Specifies the operation to be performed. Reserved for future expansion. This parameter must be set to M_DEFAULT.

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