Verifying an Image DatabaseCognex VisionPro

An application that uses the Inspection Designer capabilities of VisionPro analyzes an image for an Accept/Reject result and then compares it to the same image in a database where a result for that image has already been assigned. Inspection Designer components allow to you confirm that your vision application is generating the desired results for images you have previously analyzed manually.

To use the Inspection Designer features, you must first generate a database of graded images using the Image Grading Utility. Once the database is created, you create a CogToolBlock of vision tools to analyze those same images stored in a separate location (file or folder), and then use the Verification control of the CogToolBlock to iteratively compare an analysis of every image with its corresponding match in the graded database. The Verification control can graphically depict which analyzed images match or do not match the expected result.

If the results generated by the CogToolBlock do not match the results of the database, you can adjust the parameters of the vision tools you are using or try an alternative approach to the vision solution.

See the topic Inspection Designer for other details, and the topic Using a CogToolBlock for details on using a CogToolBlock and its Verification control.

Example Application

The following example shows you how to use QuickBuild to configure a CogToolBlock and compare an archive of images with a database of image records. The CogToolBlock must correctly determine the orientation and grade for each image as shown in the following examples:

Framework Inspection Walkthrough Image Validation Good And Bad

Creating a Database of Graded Images

To start, you must use the Image Grading Utility to grade a set of images stored in an image-database file.

  1. Choose Start->Cognex->Utilities->Image Grading Utility.

    The Image Grading Utility launches as shown:

    Framework Inspection Walkthrough Image Validation EmptyIGU

  2. Click the Connect to database icon on the top left of the utility and choose Connect.

    The utility connects to a database specified by directory name.

  3. Create a new database by clicking Make New Folder and creating a new directory for storing the verification records.

    This example creates a database in the directory C:\Verification.

  4. Click the Import images icon along the top to select the image database file bracket_std.idb in the directory %VPRO_ROOT%\Images.

    This example uses an image archive, but you can alternatively select individual files with a variety of file formats.

  5. Keep the default import option of Accept for the default grade and click OK.

    The Image Grading Utility creates a database record for each imported image, and assigns each a result of Accept. For example, the following figure shows the Image Grading Utility and the first record:

    Framework Inspection Walkthrough Image Validation First Record

  6. Advance through the database and change the result for the second and third records to Reject.
  7. For each record, assign a grade to describe the orientation of the bracket. For example, the following figure shows the third record with a grade of Left.

    Framework Inspection Walkthrough Image Validation Left Bracket

  8. Close the Image Grading Utility.
Creating a CogToolBlock to Analyze the Images

With the database created, perform the following steps to design a QuickBuild application to analyze the same images from the image archive and determine a result for each bracket:

  1. Launch QuickBuild.
  2. Double-click on the Image Source for CogJob1 and configure the image to use the image database file bracket_std.idb, installed by default in %VPRO_ROOT%\Images.
  3. Run the Job once to give it an initial image, as shown:

    Framework Inspection Walkthrough Image Validation Initial Image

  4. Add a CogToolBlock to CogJob1 and link the OutputImage from the Image Source to the CogToolBlock, as shown:

    Framework Inspection Walkthrough Image Validation Link ToCTB

  5. Open the CogToolBlock and rename OutputImage to InputImage.
  6. Add a CogPMAlign tool to the CogToolBlock and configure it to locate a corner of the bracket as shown:

    Framework Inspection Walkthrough Image Validation PMAlign Ready

  7. Add a CogResultsAnalysis tool to the CogToolBlock.
  8. Open the CogResultsAnalysis tool and create an input named Raw_Rotation:

    Framework Inspection Walkthrough Image Validation Raw Terminal

  9. Assign the Rotation result of the CogPMAlign tool to the Raw_Rotation input of the CogResultsAnalysis tool:

    Framework Inspection Walkthrough Image Validation Assign Raw

  10. Configure the CogResultsAnalysis tool to generate a Reject result if the bracket does not appear flat in the image. In addition, generate a Grade expression that can be assigned a grade of "Flat", "Left", or "Right". The following figure shows how a CogResultsAnalysis tool can be configured to generate these results:

    Framework Inspection Walkthrough Image Validation Configured Results Analysis

    Be aware that you must output the Grade expression.

  11. Pass the Grade expression as an output to the CogToolBlock:

    Framework Inspection Walkthrough Image Validation Grade Output

  12. Test the Job several times with all the images in the image-database to verify that the CogToolBlock generates the correct result for the result and the Grade.
Verifying the Image Database

With the CogToolBlock configured you can now verify the image archive against the database generated with the Image Grading Utility.

  1. Click on the Verification button along the top of the CogToolBlock to open the Verification control, which appears as shown in the following figure:

    Framework Inspection Walkthrough Image Validation Empty Validation

  2. Click the Connect to database icon on the top-left of the Verification control to connect to the C:\Verification database created earlier in this example.
  3. Click the Run verification button along the top of the Verification control to perform a comparison.

    The Verification control compares each image of the image archive in bracket_std.idb to the image database and displays the results as shown:

    Framework Inspection Walkthrough Image Validation Done Validation

  4. Scroll through the results of the verification and observe how it returned accurate results for images marked as Accept in the Image Grading Utility and for images marked as Reject, as well as determining the right grade for each record.