OCV Tool Edit ControlCognex VisionPro

The OCV tool edit control provides a graphical user interface to the CogOCVTool tool, which you use to verify the presence of a string of alphanumeric characters, logos, or other symbols in an acquired image. The edit control allows you to create individual font models, build a font of the font models that can appear on the objects you are inspecting, define a character string to verify, and then define the expected location of each font model in the string with respect to each other. The following figure shows the OCV tool edit control:

CognexOC OCV Tool OCVTool Whole Control

The edit control offers the following features:

  • A row of control buttons at the top left provide access to the most common operations.
  • A set of function tabs allow you to define a font, train the character pattern, select display graphics, and view results.
  • An image display window displays acquired images and graphical results of the OCV tool.

You can experiment with the edit control by using QuickBuild to create a CogOCV tool. A new CogOCV tool appears with the input terminals shown in the following figure:

CognexOC OCV Tool OCVTerminals

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

CognexOC OCV Tool OCVControl Buttons

The following table describes the function of each button:

Table 1. Control buttons
ButtonDescriptionFunction
Run Button
RunSearch the image stored in the Current.InputImage buffer for the trained character pattern.
Electric Button
Electric modeToggle electric mode, where the OCV tool analyzes an image automatically when particular configuration parameters change. In electric mode, a lightning bolt appears next to every electric property.

Local Display Button

Local image display

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

  • The Current.InputImage buffer contains the current image and character pattern graphics.
  • The Current.PatternReferenceImage buffer contains the reference image along with graphics to configure the pattern origin and the font models you need to create.
  • The LastRun.InputImage buffer contains the results of the OCV tool after it searches the image for the character pattern.
Floating Display Button
Floating image displayOpen one or more floating image windows, which support the same image buffers as the local image display.
Open Button
OpenOpen a VisionPro persistence (.vpp) file containing a set of saved properties for an OCV tool. 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 Save dialog box 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 OCV tool to its default state, which causes the OCV tool to remove the following:

  • All images from all of its image buffers
  • The current font
  • Any trained pattern

Resetting the OCV tool does not remove any font models that currently exist but have not yet been added to the current font. Likewise, any information about a blank font model that has not been added to the font will also remain after a reset.

CognexOC OCV Tool Floating Results
Floating ResultsOpens a separate results window with the same contents as seen in the Results tab.
CognexOC OCV Tool Font Editor
Font EditorOpen the Font Editor, which you use to create font models and build a font of characters that can appear in the objects you want to inspect. See the topic How To Use the Font Editor for details on working with font models.
CognexOC OCV Tool Create New Font
New FontDiscard the current font and start with a blank font. A dialog box warns you that you are discarding all changes. See the topic How To Use the Font Editor for details on creating font models.
CognexOC OCV Tool Load Font
Load Existing FontLoad an existing font from a .vpp or .ocf file. Once loaded, the new font appears in the Font tab.
CognexOC OCV Tool Save Font
Save FontSave the current font to the last specified font file. If the font has not yet been saved then the Save As dialog box appears.
CognexOC OCV Tool Save Font As
Save Font AsSave the current font to a new file, in either VisionPro (.vpp) or CVL (.ocf) format.
CognexOC OCV Tool Compile Font
Compile FontCompile the current font, merging the font models, character instances, and confusion scores into a logical collection that you can now use to specify a character pattern you want the tool to search for in successive run-time images. See the topic How To Use the Font Editor for details on creating font models.
CognexOC OCV Tool CVLArchive
Export the pattern to a CVL archiveSave the current character pattern as a Cognex Vision Library (CVL) arrangement so it can be used in CVL applications.
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 view the font models of the current font. To build a font you use the Font Editor. The following figure shows a Font tab with a font of 9 separate characters (3 of which have a second character instance):

CognexOC OCV Tool OCVFont Tab

The Font tab provides the following information about each font model in the font:

Table 2. Font Information
FieldDescription
DescriptionView the description of the font you supplied in the Font Description field of the Font Editor. If you do not provide a description of the font, this field appears empty.
FontModelsThis frame contains 14 thumbnail spaces for the first 14 characters models defined in the current font. If the font contains more than 14 font models, the scroll bar on the side of the frame allows you to scroll through them. The currently selected font model appears in the larger image at the bottom half of the tab, which also displays the model origin and any defined mask.
NameYou define the name for this font model when you create it. Typically, you give a font model the name of the character, or a name such as "logo" when the model defines a graphic.
InstanceMultiple font models with the same name are given instance numbers. The OCV tool numbers each character instance automatically, starting at index 0, but allows you to choose a different starting index if necessary for your application.
TypeEvery font model you create must be a normal font model or a blank font model.
WidthThe tool stores the width of the font model, in pixels.
HeightThe tool stores the height of the font model, in pixels.
Pattern Characters Tab

Use the Pattern Characters tab to define the pattern of characters the OCV tool will search for. The following figure shows an example Pattern Characters tab:

CognexOC OCV Tool OCVPattern Tab

Train

Use the Train button once the Reference Image shows the expected location of each font model and you place the pattern origin in the desired location, preferably near the first character or even on top of the font model origin of the first character. Training a pattern groups together the current font and the character pattern along with the expected locations for each font model and the pattern origin. Training a pattern might take several seconds depending on the size of the character pattern and any uncertainty values you provide. Once a pattern has been trained, the message "Pattern Trained" appears along the bottom of the OCV edit control. See the topic How To Train a Character String Pattern for more information. Changing any feature of the trained pattern will cause the pattern to become untrained.

Grab Reference Image

Use the Grab Reference Image button to copy the image currently stored in the Current.InputImage buffer to the Current.PatternReferenceImage buffer. Once a font has been loaded and you have entered a character pattern, you use the Reference Image to precisely locate the expected location of each font model in relation to each other, as well as position the pattern origin that the tool will use to report the pose of the entire pattern in each acquired image.

The Current.PatternReferenceImage buffer exists solely to provide you with a visual method for positioning the expected location of each font model in the string pattern with respect to each other, and not to specify the expected location of the string on each acquired image. You use the Current.InputImage buffer to set the expected location of the string pattern for each acquired image. See the topic How To Train a Character String Pattern for more information.

Show/Hide Advanced Items Button

CognexOC OCV Tool OCVShow Hide

Use the Show/Hide Advanced Items button to enable the controls that allow you to specify multiple font models for one or more character positions. You need to use these controls when you want the OCV tool to verify strings where one or more characters within the string are allowed to vary, such as the string "A123" or "B123", where the first character of the string can be either "A" or "B".

With advanced items enabled the Pattern Characters tab looks as shown in the following figure:

CognexOC OCV Tool OCVPattern Advanced

See the topic How To Train a Character String Pattern for details on how to define both a simple and an advanced character string.

Verification Characters

CognexOC OCV Tool OCVVerification Chars

The text box on the left shows the current character string pattern the tool is configured to verify. If it is a simple character string, such as "A0221", the text box looks as shown in the following figure:

CognexOC OCV Tool OCVSimple String

If you have configured an advanced character string, the edit control uses a "*" to indicate which character in the string is allowed to vary. For example, the following figure shows a character string where the first character is allowed to vary:

CognexOC OCV Tool OCVAdvanced String

Edit and Layout

CognexOC OCV Tool OCVEdit Layout

Click the Edit and Layout button to create a simple character string pattern, where no characters in the string can vary between font models. See the topic How To Train a Character String Pattern for details on how to define a simple character string.

Character Position Settings

CognexOC OCV Tool OCVPosition Settings

Use the Default Uncertainties fields to set the following uncertainty parameters:

Table 3. Default Uncertainties
ParameterDescription
TranslationUncertaintyEnter the expected range of image-to-image variation in the translation of any character, expressed in the units of the Selected Space Name.
ScalingUncertaintyEnter the expected range of image-to-image variation in the overall scaling factor for any character.
RotationUncertaintyEnter the expected range, in radians or degrees, of the image-to-image variation of the overall rotation for any character with respect to the pattern origin.

Use the Default Thresholds fields to set the following thresholds:

Table 4. Default Thresholds
ThresholdDescription
RunTimeAcceptThresholdEnter an accept threshold to apply to each character position.
RunTimeConfidenceThresholdEnter a confidence threshold to apply to each character position.

Use the Advanced Parameters button to specify various threshold, uncertainty, and position values for individual characters. For example, the following figure shows the Advanced Character Position Settings dialog box with the accept threshold for the font model "A" set to a higher value than the default accept thresholds for the other font models:

CognexOC OCV Tool OCVAdvanced Character

Fields that appear in grey use default values. You may change the values of fields that appear in grey, but their values cannot take effect until you enable the appropriate checkbox.

Advanced Items

CognexOC OCV Tool OCVAdvanced Stuff

The font model text boxes across the top show the current font models, if any, currently configured in the character string pattern. For example, the following figure shows how the tab appears when the character string pattern is "A02211" (which is actually a simple character string pattern):

CognexOC OCV Tool OCVAdvanced Fonts

The boxes use an arrow to indicate that a particular character is defined by multiple character instances, as shown in the following figure:

CognexOC OCV Tool OCVMultiple Instances

Finally, when a particular character in the string is allowed to vary between different characters, the box for that character uses a "*", as shown in the following figure:

CognexOC OCV Tool OCVAsterisk

For details on creating an advanced character string, see the topic How To Train a Character String Pattern.

Origin / Run Params Tab

Use the Origin / Run Params tab to set a precise location for the pattern origin and the expected location for the pattern in each run-time image. The following figure shows an example Origin / Run Params tab:

CognexOC OCV Tool OCVOrigin Run Params Tab

Train Button

CognexOC OCV Tool OCVTrain Button

Use the Train button once the Reference Image shows the correct location of each font model along with the desired position of the pattern origin. Training a pattern groups together the current font and the character pattern along with the expected locations for each font model and the pattern origin. Training a pattern might take several seconds depending on the size of the character pattern and any uncertainty values you provide. Once a pattern has been trained, the message "Pattern Trained" appears along the bottom of the OCV edit control. See the topic How To Train a Character String Pattern for more information. Changing any feature of the trained pattern will cause the pattern to become untrained.

Pattern Origin

CognexOC OCV Tool OCVPatt Origin

The easiest way to set the location for the pattern origin with respect to the characters you want to search for is to use the graphics on the Reference Image. Use the Pattern Origin area of the tab to explicitly set various parameters for the pattern origin in addition to its default (x, y) coordinate. For best results, Cognex recommends you define the pattern origin to be at the origin or at the center of the first character in the pattern. Placing the pattern origin farther away from the character string pattern can lead to errors when the pattern rotates and you rely on a combination of a PMAlign tool and Fixture tool to accurately locate the area of the image where the string can occur.

The following table lists the parameters you can modify:

Table 5. Pattern Origin Parameters
ParameterDescription
SelectedSpaceNameSpecify which space of the input image coordinate space tree the tool uses to define the expected pattern origin.
Translation X and Translation YSpecify the expected (x, y) coordinate for the pattern origin.
ScalingSpecify a different scaling factor if you know the scale of the Reference Image does not match the images you will acquire for your application.
Aspect ratioSpecify a different aspect ratio if the pixels your camera captures are not square.
RotationSpecify an exact measurement for the rotation of the pattern origin.
SkewUse a nonzero value if your acquired images can distort a rectangle into a parallelogram.
Timeout Parameter

CognexOC OCV Tool OCVRun Timeout

Enable the RunTimeTimeout parameter to enter the maximum execution time, in milliseconds, allowed to run an OCV inspection. If the tool has not finished by the end of the timeout period, the tool returns an error.

Runtime Position Parameters

CognexOC OCV Tool OCVRuntime Pose

Use the ExpectedPose to specify how the pattern you train relates to the input image and the range in which to search for that pattern. The following table lists the parameters you can modify:

Table 6. Pattern Position
ParameterDescription
SelectedSpaceNameSpecify which space of the input image coordinate space tree the tool uses to define the expected position of the pattern.
Translation X and Translation YSpecify the expected (x, y) coordinate for the overall pattern.
ScalingSpecify a different scaling factor if you know the scale of the Reference Image does not match the images you will acquire for your application.
Aspect ratioSpecify a different aspect ratio if the pixels your camera captures are not square.
RotationSpecify an exact measurement for the rotation of the pattern origin.
SkewUse a nonzero value if your acquired images can distort a rectangle into a parallelogram.

Use the Uncertainties fields to set the following uncertainty parameters for the entire pattern:

Table 7. Default Uncertainties
ParameterDescription
TranslationUncertaintyEnter the expected range of image-to-image variation in the translation of the pattern, expressed in the units of the Selected Space Name.
ScalingUncertaintyEnter the expected range of image-to-image variation in the overall scaling factor for the pattern.
RotationUncertaintyEnter the expected range, in radians or degrees, of the image-to-image variation of the overall rotation for the pattern with respect to the Selected Space Name of the input image.
Graphics Tab

Use the Graphics tab to choose which graphics appear over any of the image buffers. The following figure shows the Graphics tab:

CognexOC OCV Tool OCVGraphics Tab

Results Tab

Use the Results tab to view the results of the OCV tool after it searches the Current.InputImage for the verification string. The following figure shows an example Results tab after a successful execution:

CognexOC OCV Tool OCVResults Tab

The Results tab provides the following information:

Table 8. Result Tab
ResultDescription
StatusView the overall status of this OCV inspection, either "Verified" or "Failed"
ScoreView the overall score for this OCV result, an average of scores of all the characters in the pattern. The score has a range of 0.0 (no match) through 1.0 (perfect match).
GetPoseView information about where the OCV tool located the pattern and any changes in scale, aspect ratio, rotation, and skew with respect to the Selected Space Name.
Character ResultsView a grid of result information for each individual character in the verification string. The position values are the results for each character with respect to the found pattern, which can make it easier for you to compare the actual found position to the values you specified as you trained the pattern.