OCVMax Tool Edit ControlCognex VisionPro 9.5

The OCVMax tool edit control provides a graphical user interface to the CogOCVMaxTool tool, which you use verify that one or more character strings in an image contain the expected characters at each position. Vision applications typically use OCV to verify lot codes, date codes, expiration dates, and other information printed on products or packaging.

The OCVMax tool edit control allows you to select a font file, specify a character string to verify, and modify an array of image search parameters for successfully locating both the entire string and individual characters within the string in each acquired image. The following figure shows an OCVMax tool edit control:

CognexOCVMax OCVmax OCVMax Whole Control

The edit control offers the following features:

  • A row of control buttons along the top of the control
  • A set of function tabs for selecting the proper font, specifying the character string, modifying search parameters, and viewing results
  • An image display window for displaying acquired images and graphical results of the OCVMax tool

Use QuickBuild to create a CogOCVMax tool. A new CogOCVMax tool appears with an input terminal for the InputImage and output terminals for results indicating whether all the character positions in the arrangement have been verified along with an overall verification score for the string, as shown in the following figure:

CognexOCVMax OCVmax OCVMax Terminals

To include the edit control in your custom vision application, you must first add it to your Visual Studio.NET development environment. See the topic Adding Edit Controls to Visual Studio for more information.

Control Buttons

Table 1. OCVMax Edit Control Control Buttons
ButtonDescriptionFunction
Run Button
RunSearch the Current.InputImage for the configured character string and perform an OCVMax verification of the characters it contains.

Local Display Button

Local image display

Open or close the local image display window. An OCVMax tool supports the following image buffers:

  • The Current.InputImage buffer contains the next image with a character string the OCVMax tool will analyze, plus any verification graphics you might enable.
  • The LastRun.InputImage buffer contains the last image analyzed with the OCVMax tool.
Floating Display Button
Floating image displayOpen one or more floating image windows, which support the same image buffers as the local image display window.
Open Button
OpenOpen a VisionPro persistence (.vpp) file that contains a set of saved properties for this vision tool object type. VisionPro reports an error if you try to open a .vpp file for another object type.
Save Button
SaveSave the current properties of the vision tool to a VisionPro persistence (.vpp) file. The edit control allows you to choose between saving the vision tool with or without its image buffers and tool results.
Save As Button
Save AsSave the current properties of the vision tool to a new VisionPro persistence (.vpp) file.

Reset Button

Reset

Reset the vision tool to its default state.

The tool gives you a choice between resetting to the default-constructed state, which is appropriate when you are using it in a Visual Studio.NET application, or its template-initialized state, which is appropriate for QuickBuild applications.

Floating Results
Show Floating ResultsOpen a separate results window with the same contents as seen in the Results tab.
Tool Tips Button
Show ToolTipsEnable or disable the display of tooltips for individual items in the edit control.
Help Button
HelpOpen this VisionPro online help file.
Font Tab

Use the Font tab to select the font used in the character string you want to verify. The following figure shows the default Font tab:

CognexOCVMax OCVmax OCVMax Font Tab

Use the following controls to select the correct font for your character string:

Table 2. Font Tab
ControlDescription

[P:P:Cognex.VisionPro.OCVMax.CogOCVMaxFont.FontName]

Click Browse to open a dialog box that lets you select a file containing a single font or multiple fonts. Be aware that you cannot select a font from the /WINDOWS/Fonts directory. If you need a font file from that directory, first copy it to any other directory and select it from there.

An OCVMax tool can load the following font file types:

  • .ttc: TrueType collection font file (a font file that contains multiple TrueType fonts)
  • .ttf: TrueType font
  • .cst: Domino stroke font
  • .gcg: Imaje raster font
  • .ffn: Markem raster font
  • .xcl: VideoJet raster font
  • .fnt: Zebra raster font (many other font files may also use this extension)
  • .bdf: Glyph Bitmap Distribution Format font
  • .ocf: Cognex image font file
  • .ocm: Cognex extended image font
GetAvailableFontNamesIf you choose a font file containing multiple fonts, select the particular font file you want to use. If the font file you chose contains only one font, this field displays Single Font File.

GetAlphabetCharacters

The edit control displays each character key in the font. Enable those character keys that can appear in the character string you want to verify. Restricting the set of keys to just the characters that can appear in the character string prevents the tool from comparing the characters you want to verify with irrelevant characters, which reduces the amount of possible confusion and improves the overall performance of the tool.

Use the following buttons to select specific groups of character keys all at once:

  • Upper: All uppercase letters
  • Lower: All lowercase letters
  • Numbers: All numbers
  • All: All the character keys in the font.
  • Clear: Un-select all character keys in the font

You must enable punctuations marks individually.

PolarityChoose whether the characters in the string are dark on a light background or light on a dark background.
Tune After TrainPerform the tuning operation after the tool has been trained with the character string you want to verify.
TrainTrain the OCVMax tool with the character string you want to use. You must specify the character string on the Text tab before you can train the tool.
Text Tab

Use the Text tab to specify the character string you want to verify. The following figure shows the default Text tab:

CognexOCVMax OCVmax OCVMax Text Tab

Table 3. Text Tab
ControlDescription
SetTextEnter the character string you want to verify, as it appears in the Current.InputImage. Once you have entered the string, click Adjust Position to position the graphics representing the character string over the actual string in the Current.InputImage.

CogOCVMaxFontRenderParams

Use the following parameters to modify how the tool displays the graphics representing the string you want to verify over the Current.InputImage:

  • SpotSizeScale: Scale the spots in a dot-matrix font. The default value of 1.0 produces no change in rendered text.
  • StrokeWidthAdded: Add to the nominal stroke width of text for the specified font. A positive value increases stroke width, a negative value decreases it. This property is typically only useful with non dot-matrix fonts, or outline fonts.
  • SpotSpacingScaleX: Scale the spacing along the x-axis of rendered spots in a dot-matrix font. The default value of 1.0 produces no change in rendered text.
  • CharacterSpacingAddedX: Add spacing along the x-axis between one character and the next on the same line. A positive value increases the space between characters, a negative value decreases the space between characters.
  • SpotSpacingScaleY: Scale the spacing along the y-axis of rendered spots in a dot-matrix font. The default value of 1.0 produces no change in rendered text.
  • CharacterSpacingAddedY: Add spacing along the y-axis between one character and the next character on the same line. A non-zero value produces a staircase-like line of text, while the default value 0.0 produces no change in rendered text. This property is rarely used.
Noise Level Specify the amount of background noise surrounding the character string you want to verify in the Current.InputImage. The OCVMax tool expects the character strings in the run-time images to have the same noise level.
Registration Mode Check Clean Print to use [T:P/ProgrammingReference/html/Cognex.VisionPro.OCVMax.CogOCVMaxCharacterRegistrationConstants] mode registration. This requires images with consistent grey levels and no defects, but provides faster operation.
Tune After TrainPerform the tuning operation after the tool has been trained with the character string you want to verify.
TrainTrain the OCVMax tool with the character string you want to use. You must specify the character string on the Text tab before you can train the tool.
Wildcards Tab

Use the Wildcards tab to establish the key set the tool uses to know which characters can be expected at every position in the character string. The following figure shows an example Wildcards tab:

CognexOCVMax OCVmax OCVMax Wildcards Tab

Table 4. Wildcards Tab
ControlDescription
PositionUse the button bar below these characters to choose which position in the string you want to define a key set of wildcards, or multiple character keys.
GetKeysetCharactersView the character keys currently enabled for this position in the character string.
Key SelectionSelect all the valid characters for this position in the character string. Be aware that specifying a mix of wildcard characters that contain both blank and non-blank characters is not recommended and can seriously impact the performance of an OCVMax tool.
ActionsBy default, additional character keys you enable apply only to the selected character position. If you select All Positions, then any additional character keys you enable apply to all positions within the string.
Selected KeysUse the Add and Delete keys to modify the set of valid character keys for the currently selected position.
VerificationTypeSet the type of verification to be performed on the associated character position. When set to Normal, the OCVMax tool will determine that each character is either Verified, Confused, or Failed. This is the default verification type for the tool. If set to Always, the OCVMax tool will always return a Verified result for each character in the string, but will determine which character in the font most closely matches the character in the image
Image Params Tab

Use the Image Params tab to set the search mode you want the OCVMax tool to use, set the accept threshold for locating the character string, and enable additional degrees of freedom depending on how the character strings in the images you acquire can vary from image to image. The following figure shows the default Image Params tab:

CognexOCVMax OCVmax OCVMax Image Params Tab

Table 5. Image Params Tab
ControlDescription
Search Mode Choose a search mode the OCVMax tool will use to locate the character string in each image.

Accept Threshold

Set the accept threshold for locating the entire string within the image.

Additional Search Parameters

The tool supports the following degrees of freedom in an effort to reliably locate the character string in successive images:

  • Angle: Specify a nominal value when you know the character strings in your run-time images have a small and precise angle of rotation, or specify a range of angles.
  • Scale, Uniform: Specify a nominal value when you know your images have a small but precise amount of change in uniform scale, or specify a range of change for the amount of scale a character string can exhibit.
  • Scale, X: Specify a nominal value when you known your images have a small but precise amount of scale change along the x-axis, or specify a range of scale.
  • Scale, Y: Specify a nominal value when you known your images have a small but precise amount of scale change along the y-axis, or specify a range of scale.
  • Shear: Specify a nominal value when you know your character strings suffer from a small but precise amount of shear, which is a deformity where the characters in the string appear at an angle but with no loss of height. Use caution before you enable a range of possible shear angles, as the OCVMax tool can require a great deal more time to analyze an image when considering shear than when analyzing the same image without considering shear.

The tuning operation can generate good starting values for these additional search parameters, but you should modify them as necessary based on testing the OCVMax tool with sample images of the character string you want to verify.

Character Params Tab

Use the Character Params tab to specify search parameters the OCVMax tool can use to locate individual characters within the string. The following figure shows an example Character Params tab:

CognexOCVMax OCVmax OCVMax Character Params Tab

Table 6. Character Params Tab
ControlDescription

Search Parameters

The tool supports the following character search parameters:

  • X-Shift:Specify how many pixels each character in the string can shift to the left or to the right in successive run-time images, as compared to the string in the training image. If you enable tuning the OCVMax tool can provide a good starting value. If the OCVMax tool reliably locates the character strings in your test images, try reducing this shift value to improve tool performance. Do not, however, reduce this parameter to a value where the tool can fail to reliably locate the character strings in possible run-time images.
  • Y-Shift: Specify how many pixels each character in the string can shift up or down in successive run-time images, as compared to the string in the training image. If you enable tuning the OCVMax tool can provide a good starting value. If the OCVMax tool reliably locates the character strings in your test images, try reducing this shift value to improve tool performance. Do not, however, reduce this parameter to a value where the tool can fail to reliably locate the character strings in possible run-time images.
  • Accept Threshold: Specify an accept threshold for each individual character in the string. Try lowering this threshold if the OCVMax tool fails to verify one or two characters in a string where the other characters are accurately verified. Once you find an accept threshold that works for all characters that should be verified, try raising the threshold in small amounts to improve execution speed for the tool.
  • Angle: Provide an angle range when one or more characters can have a different angle compared to the other characters in the same string, which can frequently happen with strings printed on a curved surface.
  • Scale, Uniform: Provide a uniform scale range.
  • Scale, X: Provide a range of scale for characters along the x-axis only.
  • Scale Y: Provide a range of scale for characters along the y-axis only.
  • Shear: Provide a range for shear when one or more characters can have a different shear value compared to the other characters in the same string. Use caution when enabling shear because an OCVMax tool can require much more time to analyze the string when taking shear into consideration.

Confusion

The Character Params tab displays the confusion matrix for this character string, and allows you to modify the following confusion matrix parameters:

Advanced Params Tab

Use the Advanced Params tab to enable a run timeout or to set advanced parameters that can improve the overall performance speed of the tool. The following figure shows the default Advanced Params tab:

CognexOCVMax OCVmax OCVMax Advanced Params

Table 7. Advanced Params Tab
ControlDescription
TrainTimeoutEnabledEnable a run timeout.
TrainTimeoutIf Timeout Enabled is checked, this is the maximum allowable time in milliseconds. If the time limit is exceeded, the tool will report that none of the characters passed verification.
EarlyAcceptThresholdThe threshold for early acceptance of a potential line match as the true instance of the line in the image. If the percentage of character keys in the line that match (i.e. are verified or confused) is above this threshold, no further searching for the line is performed. This speeds up the search process when the user knows that there will not be spurious characters in the runtime image (for example when it is known that the only text in the image will be the string to be verified).
EarlyFailThresholdThe threshold for early failure of a potential line match as the true instance of the line in the image. If the percentage of character keys in the line that match (i.e. are verified or confused) is below this threshold, the section of the image containing the potential line will not be considered any further. This speeds up the search process when you know that the image should be clean, with no missing or badly damaged characters.

ContrastThreshold

Defines the minimum acceptable contrast for a pattern instance for any of three types of searches:

XYOverlap

This is the amount of XY overlap above which two results are considered to be the same for any of three types of searches:

Results Tab

Use the Results tab to view the results of the last run of the OCVMax tool. The following figure shows an example Results tab:

CognexOCVMax OCVmax OCVMax Results Tab

Table 8. Results Tab
ControlDescription

Result

The tab displays the following results:

  • Verified: The tool reports Verified if all the characters in the string have been verified, otherwise the tool reports a Status of Failed.
  • VerificationScore: The overall score of the arrangement. This is the average of the scores of all of the character keys that the OCVMax tool attempted to verify.
  • VerificationFullViolations:

Character Results

The tab displays results for each character in the string. If for any reason a character fails to verify, the corresponding cell in the Diagnostic column displays a hint regarding which degree of freedom you should enable or increase in range on the Character Params tab:

  • A: Angle
  • X: X-Shift
  • Y: Y-Shift
  • S: Scale, Uniform
  • SX: Scale, X
  • SY: Scale, Y
  • SH: Shear