QuickBuild lets you interactively build powerful, robust, ready-to-deploy vision applications quickly. This tutorial will take you from the first step of setting up your vision tools to building an executable vision application.
Building a vision application with VisionPro is a three step process:
The application you'll be building in this tutorial counts coins in an image and determines whether the image contains a minimum number of coins. It uses the PMAlign tool to identify coins in an image and various other tools to report results.
VisionPro installs the QuickBuild icon on your Windows desktop
To launch QuickBuild, double-click the icon or choose Start->Cognex->VisionPro->VisionPro QuickBuild from the Windows Start menu. The initial QuickBuild window appears:
And now you're ready to begin.
The first thing to do in developing a vision application is to establish an image source. Typically, the image source is a camera connected to a Cognex frame grabber or a FireWire camera connected to an IEEE-DCAM adapter. When you're developing an application, however, it's convenient to use an image database. Ideally, the image database should contain a range of the kinds of images you're likely to encounter in your application.
Although in this example we use an image database, for most applications you will want to acquire images from a camera. We recommend you make a complete pass through QuickBuild -> Application Wizard -> Test, and completely debug your application. When you are ready to deploy, rerun QuickBuild and change to camera acquisition instead of using an image database, then run the Application Wizard again and prepare a deployment executable.
The following section describes how to setup a camera for acquisition in a deployed application. The section after that, Opening an Image Database, continues on with this tutorial and shows you how to use an image database for application development.
To acquire images from a camera, do the following:
QuickBuild opens a QuickBuild Job Editor dialog and then an Image Source dialog.
When your camera and frame grabber are initialized, you will see that the Image Source window now includes new tabs: Strobe and Trigger, Image Properties, and Lookup Table.
Note that the Lookup Table tab is displayed only if your camera supports a lookup table.
A live display window opens that provides a real time display of images from your camera .
Turn off Live Display to complete this setup procedure.
RGB Planer is the standard color format for VisionPro color vision tools. Grey 8 selects a true grey scale image format which is used by most vision tools. A third choice, Raw, (not shown here) is available if your camera produces a Bayer color format. If you choose to work with the Bayer format you will have to convert it to RGB Planer or Grey 8 format if you want to use it with vision tools. You can use the CogImageConvert tool to make this conversion.
Some FireWire cameras offer White Balance adjustment. If the camera associated with the Frame Grabber and Video Format you have specified supports white balance adjustment, white balance dialog will appear in the lower right-hand corner of the Settings tab as shown below.
Set the Red Gain and Blue Gain values to manually adjust the white balance. If your camera supports automatic white balance, the Auto White Balance button will also appear in your dialog. Consult your camera User's Manual for information on how to adjust the white balance for your camera.
For this example, you'll use a small database of coin images installed, by default, in \Program Files\Cognex\VisionPro\Images\coins.idb.
QuickBuild opens a QuickBuild Job Editor dialog and then an Image Source dialog.
For this tutorial, use the file coins.idb located in \Program Files\Cognex\VisionPro\Images.
A live display window opens that cycles through each of the images in the database.
At this point your job has only the image source in it. (The Image Source is a special kind of tool that is only available within QuickBuild.) You can run the job to see how an image appears in the tool group window.
In the next step, you'll add a PMAlign tool and configure it to find the coins in each image.
This example uses the CogPMAlign tool to look for round shapes (coins) in the image. The PMAlign tool uses Cognex PatMax software to locate patterns in an image. It's very fast, accurate, and flexible.
The first thing to do is add a CogPMAlign tool to your QuickBuild project.
This tells the PMAlign tool to use the image source for its input image.
The PMAlign tool can make a pattern several ways. This example uses the a round dot the size of a coin as a pattern. If you used the actual image of a coin, the tool would try to match those features as well. This example uses the PatQuick algorithm, a PMAlign tool option that improves the search speed of the tool at the cost of some accuracy. In this application, the search for coins doesn't require very high accuracy.
Double click on CogPMAlignTool1 to open the tool.
You may notice the information message that reads Pattern may contain insufficient information to measure Angle reliably. Since the pattern you're using is circular, it's expected that the PatMax software would not be able to determine if it's rotated.
Now you're ready to see how your patterns work.
When you select a row in the Results pane, the corresponding shape is highlighted in blue in the display pane.
You can use this pattern to find any round shape in an image. But since you want to find several coins of different sizes, you need to set up the tool to be more flexible with the pattern.
Creating and training the pattern tells the PMAlign tool what to look for. The run parameters tell the tool how to go about finding it.
This setting lets you select the relative sizes of the things you are looking for. In this example, you trained your pattern with the largest coin you expect. The smallest coin in this set is the US dime; its diameter is about 70% that of the largest coin, the US quarter.
The scale factor is also used to take into consideration slight differences in size and distance from the camera.
Everything should be set up now to find coins:
You're ready to run the entire job. Close the CogPMAlign tool window, or drag it out of the way, so you can see the QuickBuild job editor.
At this point in developing your vision application, you would experiment with the kinds of images you're likely to process, and adjust the tool parameters, camera alignment, and lighting. If you need to do that for this application, double-click on the CogPMAlignTool1 entry in the QuickBuild job editor.
At this point, your application does what it is designed to do: find coins in an image. Now it's time to make it more interesting. Most vision applications involve checking an image to see if it meets some criteria. In this application, you will check whether the image contains a minimum number of coins.
Every VisionPro tool has a result status that it displays at the lower left corner of the tool edit control. In the QuickBuild Job Editor, you can see each tool's status as a small icon to the right of the tool's name. The results status of the entire job depends on all of the tools in it passing.
Ideally, the PMAlign tool would pass when it finds the number of coins you want, and fail if there were fewer. But since you can use the PMAlign tool for much more than counting, it's better if you decide what information that the tool generates is relevant to your application.
To do this, you'll expose some additional results that the PMAlign tool generates, and you'll use a new tool, the Results Analysis tool to compute an inspection status for the entire job.
By default, the PMAlign tool exposes the score and pose information for the first item found. (Pose information contains information about the position and size of the found pattern.) The data you want to expose are the number of coins you expected to find and the actual number to find. To do this, you need to add terminals to the PMAlign tool.
The member browser exposes the underlying structure of the tool, which can be fairly complex. To reduce this complexity the browser provides three structure levels; Typical, Expanded and All which you can choose from the pull down menu. Typical, the default, displays only the most often used elements. Expanded displays a somewhat longer list and All displays the entire structure.
The Auto Expand pull down menu gives you the option to automatically expand commonly used property collections. When you choose Common Members, the default, common members are expanded automatically when they are displayed. If you choose None, no property collections are expanded automatically. We will use None in this example to minimize the screen clutter.
The following table shows the most commonly used property collections displayed by the browser. These property collections are implemented as classes in .NET, and most of the time they correspond to the tabs in the tool edit control.
|Property Collection (Class)||Description|
|Results||This collection of properties holds the results that the tool generates.|
|RunParams||This collection of properties contain the parameters that control how the tool runs.|
The next set of steps take you through the process of exposing the two pieces of data you want: the number of coins you expected to find and the number of coins the tool found.
The next task is to set up a Results Analysis tool to accept the values of the two new output terminals you just added.
Two new items named InputA and InputB appear in the list.
Now you need an expression to compare both values.
The expression you're going to build is one that says "Reject any results where the NumberFound is less than the Minimum."
When you do this, the entries in the Argument columns will be red, and the Value column will say ERROR. This is OK because you're not finished making the expression.
That completes the expression.
This says that the Results Analysis tool will return a Reject status whenever ExprC is True; in other words when the number of coins found is less than the minimum.
Now you need to connect the terminals you created for the PMAlign tool to the inputs of the Results Analysis tool.
Now you're ready to see how everything works. Arrange the QuickBuild Job Editor window and the CogResultsAnalysisTool1 windows so you can see both at the same time. Note that tool windows always appear in front of the job editor window.
Try changing the Approx. no. to find setting in the PMAlign tool to see how that affects running the job.
The next section shows you how to keep track of the results of your application. Keeping historical results is useful to see how your application is running, and it also makes turning your vision application into deployable software much easier.
When you're using a vision application, you often want to be able to look at previous results. QuickBuild uses the Posted Items list to hold the results of completed runs of each job. Another list, the Failure Results Queue holds the results of failed requests.
Until now, you've been using the QuickBuild Job Editor which lets you work with a job, a collection of tools. In this section, you'll be working with the main QuickBuild window which contains the entire application. In this case, the application has only one job, but in more complex situations, you would have several jobs as part of the same application.
By default, QuickBuild is set up to remember the last 32 job executions and the last 32 job failures. For this application you want the Failure Results Queue to also include those executions where the job ran correctly but the result was a rejection (not enough coins).
As you can see, the Posted Items list size is already set to 32.
The next step is to specify which results you want to save in the Posted Items list.
The Configure Posted Items browser exposes the underlying structure of the tool, which can be fairly complex. To reduce this complexity the browser provides three structure levels; Typical, Expanded and All which you can choose from the pull down menu. Typical, the default, displays only the most often used elements. Expanded displays a somewhat longer list and All displays the entire structure. For this example you will need to choose Expanded.
You'll see the three tools in your job listed by name here: the Image Source tool, the PMAlign tool, and the Results Analysis tool.
Now that you have the Posted Items list and the Failure Results Queue set up, you can see how they work.
This starts the application running. You will notice the icon to the right of the job name change from a green dot (for successful images) to a green dot with a red slash (for rejected images).
At this point you have the basic skills you need to develop and refine a vision application with VisionPro and QuickBuild. At this stage of development, you might test different image sets, refine your patterns, tailor the results you want to report, and so on.
As you make changes to your QuickBuild application, it's a good idea to save it.
QuickBuild saves applications as QuickBuild Project Files with the extension .VPP.
Once you are ready to deploy your application, you can use your saved QuickBuild application and the VisionPro Application Wizard to create an executable Windows application.
Go on to Creating a Vision Application: Using the Application Wizard to continue the tutorial.