Example Code

Pattern Matching

Code and Documents

Attachment

Overview

Demonstrates how to perform Color Pattern Matching using two steps that include learning the color pattern template defined by a Region of Interest (ROI) and then matching the learned template in the image.

 

Description

This example shows how to use the pattern matching tools in NI Vision. Pattern matching is the technique used to quickly locate known reference or fiducial patterns in an image. Pattern matching is the key to many applications. Pattern matching can provide your application with information about the presence or absence, number, and location of the model within an image. 

Pattern matching is typically used in three general applications areas: 

  • Alignment -- Determine the position and orientation of a known object by locating features. The features are used as points of reference on the object. 
  • Gauging -- Measure lengths, diameters, angles, and other critical dimensions. If the measurements fall outside of set tolerance levels then the component is rejected. Gauging sometimes is used in-line with the manufacturing process and off-line. If the measurements are made off-line, a sample of components is used to determine the quality of a lot or batch of manufactured components. 
  • Inspection -- Detect simple flaws, such as missing parts or unreadable printing. 

 

Hardware and Software Requirements

LabVIEW 2014 or compatible

Vision Development Module 2014 or compatible

 

Steps to Implement or Execute Code

  1. Download the zip file below or find the example by going to Help >> Find Examples >> Toolkits and Modules >> Vision >> Pattern Matching, and open the Pattern Matching.vi
  2. Run the Pattern Matching.vi.
  3. Draw a ROI in the image to define the template. The learned template is displayed in the Template display and the match results are overlaid on the Image display.

 

Additional Information or References

 

Front Panel:

Front Panel.PNG

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors