OCRMax

Reads and/or verifies a text string within a Region of Interest (ROI), after being trained with user-defined character fonts.

The OCRMax function performs Optical Character Recognition through a process of segmentation and classification. Segmentation occurs first and uses threshold techniques to identify the areas of the image that appear to contain lines of text. After the text has been segmented into characters, the characters are trained and stored as a font database. Classification occurs during run-time, and is responsible for “reading” any text found after the function performs segmentation. This is done by comparing the images of the segmented characters to the trained characters in the font.

During the segmentation process, the OCRMax function determines the location of the line of text within the ROI, and calculates the text's angle, skew and polarity. The region is then normalized to remove unwanted noise before being binarized into foreground and background pixels. Within the binarized image, blob analysis is performed to produce character fragments, with each character fragment representing a single blob. The character fragments are then grouped together to form characters, and the characters are assigned a character region. The character region is a tight, non-editable bounding box enclosing all of the foreground (i.e. ink) pixels in the ROI.

The line of text within the ROI is split into images of the individual characters, and each character is enclosed within a non-editable character rectangle. The ROI defines the approximate location, angle and skew of the line of text. The Angle Range and Skew Range parameters on the Segmentation tab can be used to compensate for variations, if necessary.

OCRMaxInputs

Auto-Tune: Launches the Auto-Tune dialog, which is used to automatically calculate the optimal Segmentation parameters, and train a font database. With one or more images loaded, and with the Auto-Tune dialog running, each image is examined to verify that the characters are being correctly segmented and classified. If the characters are not being correctly segmented, the OCRMax function's Auto-Tune algorithm will calculate the optimal Segmentation parameters that segment the current image, as well as the previously trained images. As more images are trained, the OCRMax function's Auto-Tune algorithm will become more reliable and accurate. Once satisfactory results are achieved, the Auto-Tune dialog is closed, the new Segmentation parameters are applied and the font database is updated with the newly trained characters.

The Auto-Tune dialog provides two primary advantages over manually tuning the Segmentation parameters:

  • Images only need to be cycled through once, instead of twice (once to tune the Segmentation parameters, and the second to train).
  • Read accuracy should improve because the characters are trained automatically with the Segmentation parameters obtained during the tuning process.
Note: The OCRMaxAutoTune function provides external access to the Auto-Tune dialog, for use with external devices, such as the VisionView Operator Interface Panel. For more information, see OCRMaxAutoTune or Auto-Tune.

General Tab

Syntax: OCRMax(Image,Fixture.Row,Fixture.Column,Fixture.Theta,Region.X,Region.Y,Region.High,Region.Wide,Region.Angle,Region.Curve,Font,External Settings,Train Mode,Train String,Train Font,Clear Font,Inspection Mode,Match String,Field String,Field Definitions,Spaces. Find Spaces,Spaces. Space Score Mode,Spaces. Space Minimum Width,Spaces. Space Maximum Width,Accept Threshold,Confusion Threshold,Use Subsampling,Timeout,Output Image Graphic,Character Label Position,Show Diagnostics,Curved Region Position,Reset,Show)

Parameter Description

Image

Specifies a reference to a spreadsheet cell that contains an Image data structure; by default, this parameter references A0, the cell containing the AcquireImage Image data structure. This parameter can also reference other Image data structures, such as those returned by the Vision Tool Image functions or Coordinate Transforms Functions.

Fixture

Defines the Region of Interest (ROI) relative to a Fixture input or the output of a Vision Tool function's image coordinate system. Setting the ROI relative to a Fixture ensures that if the Fixture is rotated or translated, the ROI will be rotated or translated in relation to the Fixture. For more information, see Fixture and Vision Tools Functions.

The default setting is (0,0,0), the top leftmost corner of the image.

Row (default = 0)

The row offset, in image coordinates.

Column (default = 0)

The column offset, in image coordinates.

Theta (default = 0)

The angle of orientation, in the image coordinate system.

Region

The Region of Interest (ROI) specifies the region of the image that undergoes analysis and creates a rectangular image region that can be transformed and rotated. For more information, see Interactive Graphics Mode.

Tip: With this parameter selected, you can press the Maximize Region button on the property sheet's toolbar to maximize the region and cover the entire image.

The X-axis of the ROI should be parallel to the baseline of the text, and the Y-axis should be parallel to the vertical strokes of the characters; if there is no skew, the Y-axis is perpendicular to the X-axis. The positive direction of the X-axis corresponds to the reading direction.

Note: The baseline of the text may have any angle (0-360) in the image, as long as the ROI is oriented at approximately the same angle.

The ROI should only contain one line of text to be read, and some surrounding background. The background can be noisy and have significant background gradients/shading. In images with text that are clearly printed and have little noise, the ROI may be significantly larger than the line of text. For noisy images, the ROI should be relatively tight around the line of text.

Note: The ROI shouldn’t contain any other significant features in the image, other than the line of text. For example, the ROI shouldn’t partially enclose a different line of nearby text, or the edge of a label.

As an approximate rule of thumb, the ROI should be larger than the line of text by at least half a character width on all sides, if possible (i.e. unless a border that large would cause other features to be enclosed within the ROI).

X

The x-offset of the origin, in fixture coordinates.

Y

The y-offset of the origin, in fixture coordinates.

High

The dimension along the region's x-axis.

Wide

The dimension along the region's y-axis.

Angle

The orientation, in fixture coordinates.

Curve

The angular deviation between the region's x-axis and the opposing boundary line.

Font

Optionally, specifies a cell reference to a data structure output by another OCRMax function, containing a trained font.

Note: If a reference is set, and the trained characters are edited in the function referencing the trained font, the changes to the trained characters will not be undone if the Undo button is pressed.

External Settings

Optionally, specifies a cell reference to a data structure output by an OCRMaxSettings or GetInternalSettings function. If the Export to Cell option has been utilized, this parameter will automatically be set as an absolute cell reference to the newly created OCRMaxSettings function's Settings data structure. For more information, see OCRMaxSettings

Note:
  • If this parameter is set as a reference to an OCRMaxSettings function, the Segmentation parameters will be disabled (use the GetInternalSettings function if the parameters need to remain enabled). Set this parameter to 0 to re-enable the Segmentation parameters.
  • The Auto-Tune dialog will be unavailable if this parameter is set as a reference to an OCRMaxSettings or GetInternalSettings function (this parameter must be set to 0 to enable the Auto-Tune dialog). For more information about enabling the Auto-Tune dialog in conjunction with a GetInternalSettings function, see GetInternalSettings(OCRMax)

Train Mode

Specifies the font training behavior.

0 = Add All Characters to Font

When the Train Font parameter is activated, all of the characters in the ROI will be added to the font.

1 = Add New Characters to Font (default)

When the Train Font parameter is activated, only new characters in the ROI will be added to the font.

2 = Replace Trained Characters in Font

When the Train Font parameter is activated, all of the trained characters will be replaced with those currently in the ROI.

3 = Replace Entire Font

When the Train Font parameter is activated, all of the characters in the font will be replaced with those currently in the ROI.

Train String

Specifies the text string to be trained.

Note: The OCRMax function only supports training ASCII characters.

Train Font

Specifies the event on which to train the characters, based on the Train Mode parameter setting.

Clear Font

Specifies an event on which all of the characters in the font will be removed.

Note: The Train Font and Clear Font parameters can reference the same event, which will initiate the removal of all the characters in the font, and retraining based on the current characters within the ROI.

Inspection Mode

Specifies the inspection mode of the function during run-time.

Read (default)

The function will attempt to read the characters in the ROI, based on trained instances of the characters.

Read/Verify

The function will attempt to first read the characters in the ROI, based on trained instances of the characters, and then verify that the read characters correspond to the text string specified in the Match String parameter.

Match String

Specifies the text string that must be correctly matched when in Read/Verify Inspection Mode.

Field String

Specifies the number of characters contained in the character string. Fielding is used to provide information about what characters are expected at different positions in the string. Use the controls in the Fielding tab to construct the Field String and Field Definitions (if necessary).

Note: This parameter is only available when the Inspection Mode parameter is set to Read.

Field Definitions

Optionally, the Field Definitions setting can be used to create user-defined entries for the FieldString. When included in the FieldString, these entries restrict the list of valid characters at the positions in which they are inserted. Use the controls in the Fielding tab to construct the Field String and Field Definitions (if necessary).

Note: This parameter is only available when the Inspection Mode parameter is set to Read.

Spaces

Specifies how the function will account for spaces between characters, if necessary. The OCRMax function processes inter-character gaps by classifying them as space characters, and these are user-defined.

Find Spaces

Specifies how the function will handle the insertion of space characters into gaps between other characters.

0 = None (default)

The function will never insert a space character, regardless how large the inter-character gap between characters.

1 = Insert Single Space

The function will insert a single space character per inter-character gap, regardless how large the inter-character gap between characters.

2 = Insert Multiple Spaces

The function will insert x-number (zero or more) of space characters per inter-character gap.

Space Score Mode

Specifies how the function will calculate scores for space characters.

0 = Always Score 100 (default)

Space characters will always receive a score of 100.

1 = Score Based on Clutter

The score of a space character is based on the fraction of pixels that are background; a space character that consists entirely of background pixels will receive a score of 100.

Space Minimum Width

Specifies the minimum width of a space character, in pixels (0 - 1000; default = 10).

Space Maximum Width

Specifies the maximum width of a space character, in pixels (0 - 1000; default = 100).

Accept Threshold

Specifies the minimum acceptable match score(0 to 100; default = 80) for each character. Any character with a match score below the Accept Thresh will fail.

Confusion Threshold

Specifies the minimum difference required between the match scores of the highest scoring character and the second highest scoring character (0 to 40; default = 0).

Use Subsampling

Specifies whether or not to enable image subsampling, which decreases character resolution to increase the reading speed of the function.

0 = Off (default)

Specifies that the function will not perform subsampling.

1 = On

Specifies that the function will perform subsampling.

Timeout

Specifies the amount of time, in milliseconds(0 to 30000; default = 5000), that the function will search for characters before execution is halted and an #ERR is returned. Setting the value to 0 disables the setting and a timeout is not applied.

Output Image Graphic

Specifies the type of output image that should be displayed.

0 = Input Image (default)

The input image will be displayed.

1 = Normalized Image

The normalized image will be displayed.

2 = Binarized Image

The binarized image will be displayed.

Character Label Position

Specifies where to display each character's label in relation to the character region.

0 = Above Character (default)

Each character label will be displayed above the character region.

1 = Right of Character

Each character label will be displayed to the right of the character region.

2 = Below Character

Each character label will be displayed below the character region.

3 = Left of Character

Each character label will be displayed to the left of the character region.

Show Diagnostics

Specifies which type of graphical diagnostic data to display on the image.

0 = hide all (default)

All graphical diagnostic data will be hidden, except when the cell containing the OCRMax function is highlighted in the spreadsheet.

1 = show rejected characters only

Regions around rejected characters will be drawn in red, and the mainline of the text will be enclosed in a blue rectangle.

2 = show kept fragments only

Regions around kept fragments will be drawn in cyan, and the mainline of the text will be enclosed in a blue rectangle.

3 = show rejected fragments only

Regions around rejected fragments will be drawn in yellow, and the mainline of the text will be enclosed in a blue rectangle.

4 = show all

Regions will be drawn around kept characters (green), rejected characters (red), kept fragments (cyan), rejected fragments (yellow), the mainline of the text (blue) and the extended mainline of the text (magenta).

Curved Region Position

Specifies the X and Y coordinates for where the straightened Region will be placed in the image, when a curved Region is used.

Note: This parameter is only enabled if the Region parameter Curve value is greater than 0.

X

Specifies the X coordinate where the Region should be positioned.

Y

Specifies the Y coordinate where the Region should be positioned.

Reset

Specifies that the Segmentation tab parameters will be reset to their default settings, clear font information and remove any Auto-Tune record (.rec) files associated with the function.OCRMaxSettings

Note: This button is disabled if the External Settings parameter is set as a reference to a GetInternalSettings or OCRMaxSettings function. For more information, see GetInternalSettings(OCRMax) or OCRMaxSettings.

Show

Specifies which OCRMax graphics overlay the image.

0 = hide all (default)

All graphics will be hidden, except when the cell containing the OCRMax function is highlighted in the spreadsheet.

1 = result graphics only

The character segments, with their corresponding labels, will be displayed at all times.

2 = input graphics only

The input region will be displayed at all times.

3 = show all: input and result graphics

The image region, the output image graphic and the character segments, with their corresponding labels, will be displayed at all times.

Segmentation Tab

The Segmentation tab is used to adjust and modify the settings that segment characters in the ROI. Typically, the default values and settings will read most text, however, in more challenging cases, some parameter values may need to be adjusted. In these types of cases, specifying a minimum character width, a maximum width and/or a minimum pitch (i.e. the character-to-character distance; for example, from the left edge of one character to the left edge of the one after it) will typically address the issues.

Note:
  • The parameters on this tab may not be referenced to external cells. If cell references are required, set the External Settings parameter to reference an OCRMaxSettings function.
  • If the External Settings parameter is configured to reference an OCRMaxSettings function, the controls in the Segmentation tab will be disabled.
  • While in the Segmentation tab, the ROI can be adjusted (the Edit Graphic button is enabled) and the segmentation graphics (character rectangles) will be updated as the ROI is modified.
  • When viewing the ROI and character regions, the lines of character regions may be partially hidden by the spreadsheet overlay. When adjusting the Segmentation parameters, hide the semitransparent spreadsheet overlay to prevent the character regions from being partially occluded.

Segmentation Guidelines

  • Images that contain backgrounds with strong textures and/or so much noise that the characters blend into the background will be difficult to segment.
  • The ROI should only contain the characters to be read, and not any extraneous strong features, such as other characters or label edges.
  • In instances where two characters touch, most likely, parameters will need to be adjusted. Fixed-width touching characters can be compensated for by specifying the character width; however, proportional fonts with touching characters are problematic, with the function correctly processing some cases, but not others.
  • In cases involving short lines of text (for example, three or fewer characters) or relatively short lines with a lot of line jitter, specifying the expected Angle Range should help the function properly compensate for the inherent uncertainty in determining the orientation of a short line of text.
  • All the characters in a line of characters must have the same orientation and skew.
  • For well-separated dot-matrix print (e.g. where the dots are not touching), adjusting parameters such as the Minimum Character Fragment Size may be necessary to properly segment the characters.
  • Character stroke width must be greater than or equal to two pixels.
  • The minimum character size for large characters (typically alphanumeric) is 8 x 8 pixels. The minimum character size for small characters (such as periods) is 2 x 2 pixels.
Tip: Use the Output Image Graphic parameter to view the normalized or binarized image of the characters while adjusting the Segmentation parameters (position the OCRMax property sheet so the image is clearly visible). The normalized and binarized images can be helpful diagnostic tools for understanding and fixing problematic cases.

Export To Cell

Specifies that the current Segmentation tab parameters will be exported to a cell in the spreadsheet as an OCRMaxSettings function. Once used, the Segmentation parameters will be read-only, and the External Settings parameter will be set as a reference to the newly created OCRMaxSettings function. To re-enable the Segmentation parameters, set the External Settings parameter to zero to clear the reference to the OCRMaxSettings function.

Reset

Specifies that the Segmentation tab parameters will be reset to their default settings, clear font information and remove any Auto-Tune record (.rec) files associated with the function.

Note: This button is disabled if the External Settings parameter is set as a reference to a GetInternalSettings or OCRMaxSettings function. For more information, see GetInternalSettings(OCRMax) or OCRMaxSettings.

Segmentation Parameters

Specifies the parameter settings used to perform segmentation.

Character Polarity

Specifies the polarity of the characters in the input image.

Note: To improve the performance of the function, specify the polarity of the text.

1 = Black on White

The polarity of the text is black text on a white background.

2 = White on Black

The polarity of the text is white text on a black background.

4 = Auto (default)

The function will automatically determine the polarity of text and background.

Character Width Type

Specifies how the widths of characters in the font are expected to vary, which determines how character fragments should be merged or split.

Note: The character width is the width of the character region (e.g. the bounding box of the ink), not the ROI (which would typically include padding around the character rectangle).

1 = Auto (default)

The character width is unknown; the font may have either fixed or proportional width. Character fragments that are wider than the specified maximum character width will be split into individual characters that may or may not be of the same width, depending upon where the function determines the best place to split the character fragments.

2 = Fixed

All of the character regions in the font have the same width. Character fragments that are wider than the specified maximum character width will be split into individual characters of the same width.

4 = Variable

The characters in the font may have character regions with different widths. Character fragments that are wider than the specified maximum character width will be split into individual characters that may or may not be of the same width, depending upon where the function determines the best place to split the character fragments.

Minimum Character Width

Specifies the minimum width of a character’s character region, in pixels (1 - 1000; default = 3), that a character must have to be reported. This setting helps to filter background noise or other non-text features.

Note: If the font being read contains small text features (i.e. periods, colons, hyphens, etc.), the ability to discriminate against background noise may be limited, because setting too high a minimum value may also discard real characters.

Use Maximum Character Width

Specifies whether or not the function should account for the maximum allowable width of a character’s character region. This setting may be used to help the function determine if a character fragment should be split or merged. If the character fragment should be split, the Character Width Type parameter will determine the proper technique to be used.

0 = Off (default)

The function will not account for the maximum allowable width of a character's character region.

1 = On

The function will account for the maximum allowable width of a character's region. When enabled, a character wider than the specified value will be split into pieces that are not too wide.

Maximum Character Width

Specifies the maximum allowable width of a character’s character region, in pixels (1 - 5000; default = 100).

Note: This setting will be unavailable unless the Use Maximum Character Width parameter is enabled.

Minimum Character Height

Specifies the minimum height of a character’s character region, in pixels (1 - 1000; default = 3), that a character must have in order to be reported. This setting helps to filter background noise or other non-text features.

Note: If the font being read contains small text features (i.e. periods, colons, hyphens, etc.), the ability to discriminate against background noise may be limited, because setting too high a minimum value may also discard real characters.

Use Maximum Character Height

Specifies whether or not the function should account for the maximum allowable height of a character’s character region. This value is used in two ways: First, this value is used when finding the line, as a whole, e.g. to reject vertically adjacent noise, and/or other lines of vertically adjacent characters. Second, an individual character whose height exceeds this value will be trimmed to meet this height.

0 = Off (default)

The function will not account for the maximum allowable height of a character's character region.

1 = On

The function will account for the maximum allowable height of a character's character region.

Maximum Character Height

Specifies the maximum allowable height of a character’s character region, in pixels (1 - 5000; default = 100).

Note: This setting will be unavailable unless the Use Maximum Character Height parameter is enabled.

Use Minimum Character Aspect Ratio

Specifies whether or not the function will account for the minimum allowable aspect ratio of a character, where the aspect ratio is defined as the height of the entire line of characters, divided by the width of the character’s character region.

0 = Off

The function will not account for the minimum allowable aspect ratio of a character.

1 = On (default)

The function will account for the minimum allowable aspect ratio of a character. When enabled, a character whose aspect ratio is smaller than this value (i.e. whose width is too large) will be split into pieces that are not too wide.

Minimum Character Aspect Ratio

Specifies the minimum allowable aspect ratio (0 - 500; default = 80) of a character. This setting may be used to indirectly set the maximum width of characters by using the overall height of the line of characters, where the maximum width equals the line height, divided by the Minimum Character Aspect Ratio value. Character fragments wider than allowed by this parameter will not be merged, and will be split to form two or more character fragments that are not too wide (which is controlled by the Character Width Type parameter).

Note: This setting is unavailable unless the Use Minimum Character Aspect Ratio parameter is enabled.

Angle Range

Specifies the angel search range (0 - 45; default = 0), in degrees.

Note: If the line of text experiences angular rotation or skew, and that rotation or skew is consistent across images, configure the Region to compensate for those variances. Any value above 0 will increase the execution time of the segmentation process.

Skew Range

Specifies the skew search range (0 - 45; default = 0), in degrees.

Note: If the line of text experiences angular rotation or skew, and that rotation or skew is consistent across images, configure the Region to compensate for those variances. Any value above 0 will increase the execution time of the segmentation process.

Character Fragment Merge Mode

Specifies how the function should merge character fragments when forming characters during segmentation. Determines whether or not two character fragments are required to overlap to be considered as a part of a character, or whether or not character fragments with a horizontal gap between them may be considered as part of a character.

1 = Require Overlap (default)

Character fragments must overlap horizontally, based on the value in the Minimum Character Fragment Overlap parameter.

2 = Set Min Inter-Character Gap

Character fragments with a horizontal gap between them may be merged to form characters, where any two fragments with a gap less than the value defined in the Min Inter-Character Gap parameter will be merged.

4 = Set Min Inter-Character/Max Intra-Character Gap

Character fragments with a horizontal gap between them may be merged to form characters, with the decision to merge two fragments based on the values defined in the Min Inter-Character Gap and Max Intra-Character Gap parameters.

Minimum Character Fragment Overlap

Specifies the minimum fraction (0 - 100; default = 0) by which two character fragments must overlap each other horizontally, in order for the two character fragments to be considered as part of the same character. The default value (0) will merge any two character fragments that overlap by at least 1 pixel; larger values will require that the character fragments overlap more substantially. For applications where some character pairs are intentionally overlapped horizontally (also called kerning), or cases where the Refine stage cannot completely correct for rotation and/or skew (typically because of inconsistent printing), the default value is necessary.

Max Intra-Character Gap

Specifies the maximum horizontal gap size, in pixels (0 - 1000; default = 5), that can occur within a single character, even for damaged characters.

Note: In the most common application scenario, where the gaps that occur between adjacent characters are always wider than the gaps that may occur within a broken character, set the Min Inter-Character Gap parameter to the Max Intra-Character Gap parameter value, plus 1. For example, if characters never exhibit internal horizontal gaps, the Max Intra-Character Gap parameter would be set to 0, and the Min Inter-Character Gap parameter would be set to 1.

Min Inter-Character Gap

Specifies the minimum horizontal gap size, in pixels (0 - 1000; default = 0), that must occur between two character fragments to be belong to different characters. The gap is measured from the right edge of the character region of one character, to the left edge of the character region of the next character. If the gap between two fragments is smaller than this value, then the fragments must be considered to be part of the same character, unless the combined character would be too wide (as specified by the Maximum Character Width and/or Minimum Character Aspect Ratio parameters).

Note: In the most common application scenario, where the gaps that occur between adjacent characters are always wider than the gaps that may occur within a broken character, set the Min Inter-Character Gap parameter to the Max Intra-Character Gap parameter value, plus 1. For example, if characters never exhibit internal horizontal gaps, the Max Intra-Character Gap parameter would be set to 0, and the Min Inter-Character Gap parameter would be set to 1.

Minimum Character Fragment Size

Specifies the minimum number of foreground (i.e. text) pixels (0 - 1000; default = 15) that a character fragment must have in order to be considered for possible inclusion in a character. When setting this value, it must be set so that is small enough to keep real pieces of text, while still being large enough to exclude small fragments from background noise. For dot-matrix text and/or text that contains small characters such as periods, a smaller value may be necessary. For solid stroke text, where the characters do not tend to break up into multiple, smaller pieces, a larger value may be necessary.

Minimum Character Size

Specifies the minimum number of foreground (i.e. text) pixels (0 - 5000; default = 30) that a binarized character must have in order to be reported; characters with too few pixels will be discarded. This setting helps to filter background noise or other non-text features.

Note: If the font being read contains small text features (i.e. periods, colons, hyphens, etc.), the ability to discriminate against background noise may be limited, because setting too high a minimum value may also discard real characters.

Advanced Segmentation Parameters

Specifies additional parameters to be applied during the segmentation process.

Normalization Mode

Specifies the mode used to normalize the image, which removes background variation to utilize all 256 greyscale values (0 - 255).

Note: This setting should be the same for both training and run-time; changing this setting after training may cause classification issues.

1 = None

No normalization will be performed.

2 = Global

A global normalization is performed, using information in the whole ROI, not local variations. This option is best when the background color and text are consistent across the entire ROI; also the fastest mode.

4 = Local (default)

A local normalization is performed, using information about each local character region in the ROI to normalize the image. This option removes background gradients, and should be tried if the Global mode does not work.

8 = Local Advanced

A local normalization is performed, using information about each local character region in the ROI to normalize the image, including adjustments for not only the background, but also the contrast of the foreground. This option removes background gradients and also adjusts for inconsistent text contrast; also takes the most execution time of the three options.

Use Stroke Width Filter

Specifies whether or not to remove everything from a normalized image that does not have the same stroke width as the as the rest of the image. This option can remove some types of non-text features, such as thin lines that might otherwise connect nearby characters. This option can also remove some low-contrast background variations that might otherwise exceed the binarization threshold and create false fragments and/or interconnect nearby characters. However, using this option may cause problems if the text does not have a consistent stroke width and/or the text has significant variable contrast (e.g. parts of some strokes are very faint).

Note: This setting should be the same for both training and run-time; changing this setting after training may cause classification issues.

0 = Off

The function will not remove everything in the image that does not have the same stroke width as the rest of the fragments in the image.

1 = On (default)

The function will remove everything in the image that does not have the same stroke width as the rest of the fragments in the image.

Ignore Border Fragments

Specifies whether or not the function will completely ignore any fragments that touch any border of the ROI. Ignoring such fragments can be useful for non-text features, such as the edges of labels, that might be included within the ROI.

Note: If a fragment extends from the border of the character region to the mainline of the text, the fragment will be considered to be a character. The fragment must not extend into the mainline of the text to be excluded when this parameter is enabled.

0 = Off (default)

The function will not ignore border fragments.

1 = On

The function will ignore border fragments.

Binarization Threshold

Specifies a percentage modifier (0 - 100; default = 50) in the range that is used to compute the binarization threshold, in the normalized image, that binarizes the image between text and background. For example, the default setting of 50% would produce a binarization threshold of roughly 128 (on a 0-255 greyscale range), with 0 equaling Black on White text, and 100 equaling White on Black text. Using a value less than 50% alters the binarization threshold so that there is less text and more background, whereas using a value greater than 50% produces less background and more text. Typically, the default value will correctly binarize the image; however, in cases where there is background texture or other background variations, decreasing this value may help compensate for the background variations.

Note: This setting should be the same for both training and run-time; changing this setting after training may cause classification issues.

Character Fragment Contrast Threshold

Specifies the minimum amount of contrast [in grayscale levels (0 - 255; default = 30)] of a fragment as a whole, relative to the threshold in the normalized image, in order to be considered for possible inclusion in a character. Each foreground pixel in a fragment is always guaranteed to meet the threshold, but if all of the pixels in a fragment are very close to the threshold, then the fragment is likely just noise, rather than text. A value of 0 will prevent low-contrast fragments from being rejected.

Maximum Fragment Distance to Mainline

Specifies the distance, as a percentage of character height (0 - 1000; default = 0), that a fragment may be vertically removed from the "mainline" running horizontally through the text. Ordinarily, characters are expected to lie along a straight, horizontal line after being refined (the stage of compensating for angular orientation and skew). However, characters may sometimes exhibit "jitter," where there may be vertical drift of the characters' positions. With the default setting, these character fragments would be rejected because they do not lie along the "mainline" of characters. Increasing this parameter setting allows the function to keep fragments that do not lie along the "mainline" of characters.

Segmentation Analysis Mode

Specifies the type of character analysis mode to perform to determine the optimal character segmentation. This parameter determines whether or not to perform additional analysis beyond the Group stage.

1 = Minimal

Performs basic segmentation analysis; follows the Group stage analysis only.

2 = Standard (default)

Performs additional analysis of the line as a whole, including character spacing, to determine the optimal segmentation. When enabled, the function will be affected by the Minimum Pitch, Character Pitch Type, and Character Pitch Position parameters.

Minimum Pitch

Specifies the minimum pitch, in pixels (0 - 1000; default = 0), that can occur between two characters, where the pitch is computed based on the Character Pitch Position parameter. If the pitch between two fragments is smaller than this, then they must be considered to be part of the same character, unless the combined character would be too wide (as specified by the Maximum Character Width and/or Minimum Character Aspect Ratio parameters).

Note: If the Segmentation Analysis Mode parameter is set to Minimal, this parameter will be disabled.

Character Pitch Position

Specifies how the pitch between two successive characters should be measured. Pitch is defined as the distance between (approximately) corresponding points on adjacent characters, and not the distance from the end of one character to the beginning of the next character (which is called the inter-character gap). For fixed-pitch fonts in which the characters have different widths, typically the pitch will have a consistent value only when using the appropriate pitch metric.

Note: If the Segmentation Analysis Mode parameter is set to Minimal, this parameter will be disabled.

1 = Auto (default)

Specifies that an unknown metric is being used; the appropriate pitch may be any of the other pitch positions, or else there is not a constant pitch position (as may be the case for a proportional-pitch font), and the OCRMax function will determine the appropriate pitch metric.

2 = Left-to-Left

Specifies that pitch is measured as the distance from the left-side of a character's character region to the left-side of the adjacent character's character region.

Note: The terms "left" and "right" are relative to the coordinate axis defined by the ROI, i.e. "right" is equal to the positive X direction.

4 = Center-to-Center

Specifies that pitch is measured as the distance from the center of a character's character region to the center of the adjacent character's character region.

8 = Right-to-Right

Specifies that pitch is measured as the distance from the right-side of a character's character region to the right-side of the adjacent character's character region.

Note: The terms "left" and "right" are relative to the coordinate axis defined by the ROI, i.e. "right" is equal to the positive X direction.

Character Pitch Type

Specifies whether the spacing between successive characters has a single, fixed value, or varies, depending on the particular characters. Pitch is defined as the distance between (approximately) corresponding points on adjacent characters, and not the distance from the end of one character to the beginning of the next character (which is called the inter-character gap).

Note: If the Segmentation Analysis Mode parameter is set to Minimal, this parameter will be disabled.

1 = Auto (default)

Specifies that pitch type is unknown, but the pitch type is expected to be either fixed or proportional, and not variable. The OCRMax function will determine the best type.

2 = Fixed

Specifies that pitch is fixed, which means that the pitch between any pair of characters is constant, e.g. regardless of the width of the character rectangles of the characters. The pitch is measured based on the Character Pitch Position parameter.

4 = Proportional

Specifies that the pitch is proportional, which means that the pitch between any pair of characters depends on the particular characters. For example, the distance between two "i" lowercase letters may be much less than the distance between two "M" uppercase letters.

Note:
  • Although no pitch measurement is constant throughout a string, typically the inter-character gap, which is the distance from the right-side of one character's character region to the left-side of the adjacent character's character region, is approximately constant.
  • The terms "left" and "right" are relative to the coordinate axis defined by the ROI, i.e. "right" is equal to the positive X direction.

8 = Variable

Specifies that no character-to-character distance metric is consistent throughout a string, e.g. character placement is erratic, and the pitch is neither fixed nor proportional. The OCRMax function should not try to determine the type of pitch.

Note: Variable pitch is different from Auto, since Auto assumes that the pitch is either fixed or proportional, but which is not known.

Output Image Graphic

Specifies the type of output image that should be displayed.

Note: This parameter temporarily over-rides the Output Image Graphic parameter in the General tab. After exiting the Segmentation tab, the Output Image Graphic parameter setting in the General tab will be restored.

0 = Input Image (default)

The input image will be displayed.

1 = Normalized Image

The normalized image will be displayed.

2 = Binarized Image

The binarized image will be displayed.

Show Diagnostics

Specifies which type of graphical diagnostic data to display on the image.

0 = hide all (default)

All graphical diagnostic data will be hidden, except when the cell containing the OCRMax function is highlighted in the spreadsheet.

1 = show rejected characters only

Regions around rejected characters will be drawn in red, and the mainline of the text will be enclosed in a blue rectangle.

2 = show kept fragments only

Regions around kept fragments will be drawn in cyan, and the mainline of the text will be enclosed in a blue rectangle.

3 = show rejected fragments only

Regions around rejected fragments will be drawn in yellow, and the mainline of the text will be enclosed in a blue rectangle.

4 = show all

Regions will be drawn around kept characters (green), rejected characters (red), kept fragments (cyan), rejected fragments (yellow), the mainline of the text (blue) and the extended mainline of the text (magenta).

Train Font Tab

The Train Font tab is used to train, view, rename and remove characters. The tab is divided into two groups, Characters, where the trained fonts are managed, and Training, where the character training parameters are defined.

Note:
  • The controls on this tab are not linked to the Train Mode, Train String and Train Font parameters on the General tab.
  • While in the Train Font tab, the ROI can be adjusted (the Edit Graphic button is enabled) and the segmentation graphics (character regions) will be updated as the ROI is modified.
  • Multiple-byte character names (e.g. Kanji) are not supported. Multiple-byte characters can be trained, but the name given to the character must be a single byte name.

Characters Group Box Controls

After training, each trained character will be visible in the tree, where the character will assigned a folder and label, and grouped together (if the characters have matching labels).

  • Select the root Font folder to display all of the characters in the font in the panel on the right-side. The characters will be displayed as icons with a label underneath.
  • Select a character folder to display all of the trained instances of that character in the panel on the right-side. The characters will be displayed as icons with a label underneath.
  • Select a trained instance of a character to display that character, zoomed to fit the panel on the right-side.
Tip: Providing the OCRMax function with multiple training instances of each character to be read during run-time allows the function to better discriminate between similar character types. However, training multiple instances of the same characters has advantages and disadvantages. The advantage to training multiple instances is that better classification performance can be expected, especially when reading text that could easily be mis-classified (e.g. 8 and B).The disadvantages of training multiple instances are: a decrease in the function's execution time; possible decreases in the confidence scores, because multiple training instances should not only improve the highest score, but also improve the second-highest score, as well; and possibly training bad characters.
  • Import: Launches the Open dialog, where a font, saved as an OCRMax data file (*.ocm), may be imported.

  • Export: Launches the Save As dialog, where a font can be saved as an OCRMax data file (*.ocm).

  • Rename: Press after selecting an item to rename it. Any element in the tree or in the list panel on the right-side can be renamed.

    Note: Renaming a group of characters will assign a new label to all of the characters in the group. Renaming a single character will assign a new label to that single, selected character; the character will be moved to a new or different group in the tree.
  • Delete: Press after selecting an item to remove it from the font. Any element in the tree or in the list panel on the right-side can be renamed.

    Note: Deleting the Font folder will clear the font; all characters will be deleted. Deleting a group of characters will delete all of the characters whose label matched the deleted group's label.

Training Group Box

Before characters can be trained, they must be correctly segmented.

  • Add All Characters to Font: Specifies that all of the characters in the ROI will be trained. The characters expected to be trained are entered into the Train String text entry box, before the Train button is pressed. The number of characters in the Train String text entry box must match the number of segmented characters.
  • Add New Characters to Font: Specifies that only new characters in the ROI will be trained. The characters expected to be trained are entered into the Train String text entry box, before the Train button is pressed. The number of characters in the Train String text entry box must match the number of segmented characters.
  • Add Individual Characters to Font: Specifies that specific characters in the ROI will be trained. When this option is selected, the Train String text entry box will be disabled, and the Train button will launch the Add Selected Characters to Font dialog. This dialog contains an unwrapped image of the ROI, with a label and text-entry boxes below each of the segmented characters. The label is the currently associated symbol for that character (a "?"denotes an unknown or untrained character). Below the label is a text-entry box. Enter a label for each segmented character in the text-entry box; leave the text-entry box empty to not retrain characters. Press the Train button to close the dialog.
  • Train String: Specifies the text string to be trained. The number of characters in the Train String text entry box must match the number of segmented characters.
  • Train Button: Activates training.

Fielding Tab

The Fielding tab provides a graphical means of creating and editing the Field String and Field Definitions arguments of the OCRMax function. The resulting values are inserted into the function as literal strings.

Note: If the vision system is running 5.x.x firmware, when the Inspection Mode is set to Read/Verify, the Fielding tab controls are disabled and cannot be modified.

Fielding provides the functionality to verify and correct strings, returning the set of best matching valid strings. There are two primary usages for Fielding:

  • OCR Result Verification: The string returned is determined to be correct or incorrect based on the Field String and Field Definitions parameters.
  • OCR Result Correction: The string returned is not among the list of acceptable results, and an attempt is made to find an acceptable string allowed by the field that is closest to the returned string.

A typical use-case for fielding is when the string contains prefix and/or suffix characters, and fielding is used to ignore those prefix/suffix characters. In this case, the Field String and Field Definitions determine the offset of the string position in the ROI.

Field String

Specifies the number of characters contained in the character string. A Field String entry can be any alphanumeric character found in the text entry dialog, including (A to Z), (ato z), (0 to 9), dashes(-), dots (.),and spaces ( ).

Each character in the FieldString corresponds to an indexed field position between 0 and 31. The Field String must contain at least the same number of positions as there are characters in the string for the read to pass (i.e. if there are 10 characters present, but the Field String only specifies 9 characters, the best matching 9 will be returned; however, if there are 8 characters present and the Field String defines 9 characters, the function will return #ERR). By default, each position in the FieldString is represented as an asterisk (*) character, or alphanumeric"wildcard."This means that any character is valid at any position in the string.

However, an individual position in the Field String can be limited to consider only a subset of possible characters at that position. This increases overall performance and reliability because characters that are not possible at a position will not be considered during a read.

The pre-defined FieldString entries are:

Field String

Entry

Description

Valid Characters

*

Wild card

Any trained character in the font.

N

Numeric

0123456789

A

Uppercase alphabetical

ABCDEFGHIJKLMNOPQRSTUVWXYZ

a

Lowercase alphabetical

abcdefghijklmnopqrstuvwxyz

H

Hexadecimal, uppercase alphabetical and numerical

0123456789ABCDEF

h

Hexadecimal, lowercase alphabetical and numerical

0123456789abcdef

O

Octal

01234567

Note:
  • To restrict a position in a Field String to a single character, simply enter that character. The character must have been trained in the font and cannot be one of the pre-defined FieldString entries listed above, unless it has been remapped using the Field Definitions parameter.
  • To read a string containing a space, include the space in the FieldString. ReadText will not read a space if the corresponding Field String entry in that position is an asterisk (*).
  • If the Field String parameter in the General tab is defined as a cell reference, the Field String option in the Fielding tab will be disabled, and the current value of the cell reference will be displayed.

Field Definitions

Optionally, the Field Definitions settings can be used to create user-defined entries for the FieldString. When included in the FieldString, these entries restrict the list of valid characters at the positions in which they are inserted. There are several pre-defined field definitions, and user-defined field definitions can be added. The pre-defined definitions are displayed in grey text and may not be deleted or edited, only enabled or disabled. User-defined definitions are displayed in black text, can be added, deleted or edited. To add a field definition, press the Add New button, assign an icon for the Character and then assign a definition to the Character.

Note:
  • The number of user-defined definitions is limited by the OCRMax function's expression length (249).
  • Any user-defined definitions that are disabled when the OCRMax property sheet is closed will be removed and will not be available when re-opening the function's property sheet.
  • If the Field Definitions parameter in the General tab is defined as a cell reference, the Field Definitions option in the Fielding tab will be disabled, and the current value of the cell reference will be displayed.

Characters listed for a Field Definitions entry must be contained in the font. For example: #=123 is valid if 1, 2, and 3 are included in the user-trained font. However,#=123 would be invalid if 1, 2, and 3 are not included in the font.

Note: Using one of the predefined entries (*, A, a, N, H, h, O) in the Field Definitions parameter will remap the list of valid characters in the new definition.

Field Definitions Controls

  • Match Only Against Characters in Field String: Specifies whether the function will only attempt to match characters against characters indicated by the Field String.

    Note: If the vision system is running 5.x.x firmware, when the Inspection Mode is set to Read/Verify, this parameter fields against the text string specified in the Match String parameter.
  • Variable Length Strings: Specifies whether or not the defined Field String might be a sub-string within the complete read text string. If a sub-string is found, it will return the best-match sub-string.

    Note: If the External Settings parameter is set as a reference to an OCRMaxSettings function, the Match Only Against Characters in Field String and Variable Length Strings parameters will be disabled.
  • Minimum Length: When the Variable Length Strings parameter is enabled, this parameter specifies the minimum acceptable string length (0 - 100; default = 1).
  • Maximum Length: When the Variable Length Strings parameter is enabled, this parameter specifies the maximum acceptable string length (0 - 100; default = 25).
  • Maximum Start Index: When the Variable Length Strings parameter is enabled, this parameter specifies the fielding subsequences to be considered, which must start at a position that is no greater than this index value (0 - 100; default = 100).
  • Minimum End Index: When the Variable Length Strings parameter is enabled, this parameter specifies the fielding subsequences to be considered, which must end at a position that is no smaller than this index value (0 - 100; default = 0).

Results Tab

The Results tab displays the overall results and scores for each character, and is divided into two sections: Overall Results and Character Results.

Overall Results

  • Status: Displays the function's overall result - Pass or Fail.

Character Results

  • Char: Displays the character read at that position.

  • Status: Displays the status (Bad Read, Good Read, Ignored, Confused, Mismatch, Confused Mismatch or Validation Failed) of the read character.

    • Bad Read: No characters scored high enough above the Accept Threshold to be considered a good read.

    • Good Read: The function successfully read the character at this position.

    • Ignored: When fielding is enabled, if a fielding string is specified and it is shorter than the string read by the function, the characters at the beginning or end of the string will be segmented (in yellow), but will not be included with the overall result. For example, if the fielding definition is ABC, and the string read by the function is "12ABC34", then "1234" will be ignored.

    • Confused: The function identified a character that scored high enough to be a good read (above the Accept Threshold parameter value), however, a different character scored close enough to the same score (within the Confusion Threshold parameter value), such that the function is not confident that it picked the correct character [Confused = (Primary Score - Secondary Score)/Confidence Threshold].

    • Mismatch: The function found a character that does not match the fielding, which scored much higher than any characters that do not match the fielding. It is likely that a character that does not match the fielding was printed at this position. Fielding must be enabled to return this status.

      Note: The Mismatch status is only returned if the OCRMaxSettings function is being utilized and the function's Ignore Unfielded Characters is disabled.
    • Confused Mismatch: The function found a character that meets both the requirements of Confused and Mismatch.
    • Validation Failed: If the OCRMaxSettings function is being utilized and the function's Skip Additional Character Validation parameter is disabled, the function will parse the characters through an additional validation step, to ensure that the function does not produce false reads.
  • Score: Displays a score that measures how closely the read character matches the trained character in the font database.
  • Confused With: Displays the next, best matching character.
  • Confusion Score: Displays a measure of how certain the function is of the chosen match, when compared against the next, best match.

Diagnostics Tab

The Diagnostics tab displays information about how the OCRMax function segmented characters in the ROI. This data can be useful in determining which parameters to adjust, and how much, if characters and/or character fragments are not being correctly segmented. Use this tab in conjunction with the Show Diagnostics parameter for a graphic display of the diagnostic data.

Note: This tab will update automatically when any parameters are changed and/or a new image is acquired or loaded.

Mainline Data

  • Angle: Displays the angular orientation measurement of the character regions, relative to the ROI, in degrees.
  • Skew: Displays the angular skew measurement of the character regions, relative to the ROI, in degrees.
  • Pitch: Displays the minimum and maximum pitch measurement of the characters, in pixels.
  • Inter-Character Gap: Displays the minimum and maximum measured inter-character gap, in pixels.
  • Intra-Character Gap: Displays the minimum and maximum measured intra-character gap, in pixels.

Accepted Characters

  • Width: Displays the minimum and maximum measured width of the accepted characters, in pixels.
  • Height: Displays the minimum and maximum measured height of the accepted characters, in pixels.
  • Size: Displays the minimum and maximum measured size of the accepted characters, in pixels.

Rejected Characters

  • Width: Displays the minimum and maximum measured width of the rejected characters, in pixels.

  • Height: Displays the minimum and maximum measured height of the rejected characters, in pixels.

  • Size: Displays the minimum and maximum measured size of the rejected characters, in pixels.

    Note: If there are no rejected characters, #ERR will be displayed.

Accepted Fragments

  • Size: Displays the minimum and maximum measured size of the accepted fragments, in pixels.
  • Contrast: Displays the minimum and maximum measured contrast of the accepted fragments, as a percentage.
  • Distance to Mainline (%): Displays the maximum Y distance of all the accepted fragments, as a percentage of the mainline height.

Rejected Fragments

  • Size: Displays the minimum and maximum measured size of the rejected fragments, in pixels.
  • Contrast: Displays the minimum and maximum measured contrast of the rejected fragments, as a percentage.
  • Distance to Mainline (%): Displays the maximum Y distance of all the rejected fragments, as a percentage of the mainline height.

OCRMaxOutputs

Returns

An OCRMax data structure containing the character string that was read, or #ERR if any of the input parameters are invalid.

Results

When OCRMax is initially inserted into a cell, a result table is automatically created in the spreadsheet.

OCRMaxVision Data Access Functions

The following Vision Data Access functions are automatically inserted into the spreadsheet to create the result table. For more information, see OCRMax.

String

GetString(OCRMax)

Returns the text string in the referenced data structure.

StringPass

GetPassed(OCRMax)

Returns the pass/fail status of the entire string in the referenced data structure.

Index

Char

GetChar(OCRMax, Index)

Returns the indexed character in the referenced data structure.

Score

GetScore(OCRMax, Index)

Returns the match score (0 to 100) for the indexed character in the referenced data structure.

Passed

GetPassed(OCRMax, Index)

Returns the pass/fail status of the indexed character in the referenced data structure.

2nd Char

GetChar(OCRMax, Index0, [Index1])

Returns the second highest scoring character.

2nd Score

GetScore(OCRMax, Index0, [Index1])

Returns the score of the second highest scoring character.

Char Difference

Returns the difference between the indexed character's Score and 2nd Score values.