Solving a Machine Vision Application with NI Vision Builder for Automated Inspection
Overview
Machine vision applications require a combination of hardware and software to ensure success. While choosing the right hardware is important, the visual inspection software forms the core of any machine vision system. National Instruments introduces configurable machine vision software with NI Vision Builder for Automated Inspection (Vision Builder AI).
Vision Builder AI allows you to easily configure and benchmark a sequence of visual inspection steps as well as deploy the visual inspection system for automated inspection. With Vision Builder AI you can not only perform powerful visual inspection tasks but also make decisions based on the results of individual tasks. In addition, you can communicate with external devices using serial lines and discrete I/Os. Vision Builder AI also allows you to migrate your configured inspection to LabVIEW so that you can extend the capabilities of your application by integrating motion control and data acquisition.
Table of Contents
Inspection Challenge
This document introduces the software components of a complete visual inspection system and demonstrates how you can quickly and easily configure a real-world machine vision application with Vision Builder AI. Visual inspection applications involve simple measurements, such as edge detection, gauging, counting, pattern matching, and part identification. The goal of the application described in this document is to verify the manufacturing quality of oil filter production, ensuring that the correct number of filtration holes are present and the diameter of the rubber gasket is correct. The diameter of the gasket needs to be expressed in millimeters rather than pixels so that the measurement can be compared to design specifications easily.
Vision Builder AI Interface
The Vision Builder AI interface contains the following four areas:
1. Main window—Displays the image being processed, the Decision Making property page, the Serial I/O property page, and the Configure Inputs/Outputs property page.
2. Inspection diagram window—Displays the sequence of Vision Builder AI steps that comprise the inspection.
3. Embedded help window—Contains context-sensitive help about when to use a step, how to configure a step, the function of the user-interface controls, and frequently asked questions.
4. Inspection Steps palette—Lists and describes the steps you use to create your inspection. When you click most steps, this palette transforms into the property page for the step.
Figure 1: Four Areas of the Vision Builder AI Interface
Locating the Part under Inspection
If the oil filter is fixtured, it always appears at the same location and orientation in the images you need to inspect, so defining regions of inspection is straightforward. However, if the oil filter appears shifted or rotated within the images, the regions of inspection need to shift and rotate with the filter.
For the regions of inspection to move in relation to the oil filter, you need to set a coordinate system relative to a significant and original feature of the oil filter. You should choose a feature that is always in the camera field of view despite the different locations in which the filter may appear from image to image. Also, you should make sure the feature is not affected by major defects that could drastically modify the visual appearance of the feature. The center hole of the oil filter will be the unique feature from which to base the coordinate system.
To find this hole, you can use the Match Pattern step of Vision Builder AI.

Figure 2: In the Locate Features palette you can find pattern matching, coordinate system and object detection functionality.
To configure the Match Pattern step, draw a region of interest around the area of the image containing the middle hole. This region becomes the pattern matching template. Vision Builder AI looks for and locates the specified template inside the green region of interest in the image, as shown in Figure 3. The location of the match is overlaid on the inspection image with a red rectangle.

Figure 3: Match Pattern finds the center of the hole.
You can set up the coordinate system so that it is based on the hole location you found with the Match Pattern step. In later steps you can account for motion in all directions and for rotation using this coordinate system. In this application, horizontal and vertical motion are the only directions to consider because the oil filter appears shifted in only the x (horizontal) and y (vertical) directions.
Detecting Filtration Holes
You can use the Detect Objects step to count the eight holes. Using the annulus (circle) region of interest tool, you can draw a region of interest that encircles the ring of smaller holes.
You can adjust the Threshold tab and select the Dark Objects radio button to see all the pixels that fall within the Threshold Range. These selected pixels are highlighted with blue. Vision Builder AI groups contiguous highlighted pixels into objects, which are depicted by red bounding rectangles, as shown in Figure 4. You can adjust many other parameters to fine tune the object detection by filtering on object size and objects that touch the border of the region of inspection. You can also specify how many objects should be found for the oil filter to meet specifications.

Figure 4: Detect Objects Detects Eight small holes in the filter.
Calibrating the Image
By default, Vision Builder AI returns measurements in pixels. If you want the inspection to return measurements in real-world units, you need to map pixels to the unit of your choice through a process called spatial calibration. A calibration wizard is included with Vision Builder AI. Vision Builder AI can account for linear, perspective, and nonlinear distortion. For this example, you can assume the camera that acquired the inspection images is perpendicular to the image plane and that lens distortion is negligible. Based on these assumptions, you can use simple calibration to create the pixel to real-world mapping. Simple calibration transforms a pixel coordinate to a real-world coordinate through scaling in the x (horizontal) and y (vertical) directions.

Figure 5: First Screen of the Calibration Wizard
Measuring the Gasket
One of the last steps for this inspection is measuring the diameter of the gasket using the Caliper step. You can draw a region of interest across the width of the filter, as shown in Figure 6.

Figure 6: The Caliper Step Finds the Width of the Gasket
In the Settings tab, you can specify the direction and orientation of the search lines as well as the edge detection settings.
Benchmarking the Application
The speed of an inspection system is critical, particularly so that it does not become the bottleneck of a system. Because the vision inspection performances are dependant on the machine they are performed on, Vision Builder AI provides a performance meter that allows you to benchmark the visual inspection steps on a specific configuration.
The detailed view of the Performance Meter, shown in Figure 7, helps to identify individual steps that take the most amount of time. With this knowledge, you can modify the inspection strategy to optimize the inspection time.

Figure 7: Detailed View of the Performance Meter
Deploying the Application
It takes just a few minutes to create an oil filter inspection application. The last step is to actually deploy the application. Vision Builder AI includes a built-in Inspection interface for deployment purposes. As shown in Figure 8, the Inspection interface includes everything you need to effectively run the application long term. The Display window previews the part being inspected complete with overlays and accompanying text. At the bottom of the screen, the Results panel lists all of the inspection steps, their measurements, and pass/fail information. The right portion of the screen contains the Inspection Statistics panel, which provides information that can help with quality assurance.
Figure 8: Built-In Deployable Inspection Interface
Conclusion
Using Vision Builder AI, you can create a complex inspection application in a short amount of time. Combined with the right hardware, Vision Builder AI can help you create low-cost, powerful inspection solutions.
Reader Comments | Submit a comment »
Not as easy as it appears
I find it interesting how simple you make it
look. But in reality metal varies in colour
from part to part so a gasket or no gasket
at 100+ per minute can be tricky, include a
chamfered edge in the threaded area and you
will throw off your hole gauging. Plus it
would be important to have thread quality
inspection. Lastly entering 500 hundred
different recipes poses labour intensity on
set up, and change over capacity. Especially
since the recipes are ongoing changes.
There are other issues in this process, and
I speak from experience. We have already
completed 3 projects for this specific
product inspection, but did so with a PC
based solution, and some additional software
algorithms (inhouse made)to add redundancy
and compensate for process changes.
I wonder if you have a real application in
the field working well?
- Mike Owens, Global Controls CanaVision. owensmichael@rogers.com - Oct 22, 2004
The tutorial that comes with the software
provides the exact same information. I came
to the web page to help find answers that are
beyond the basics.
- Oct 29, 2003
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).


