Chapter 5
Performing Machine Vision Tasks
IMAQ Vision for LabWindows/CVI User Manual
5-16
ni.com
the template that are necessary for shift-invariant matching. However, if
you want to match the template at any orientation, use rotation-invariant
matching. Use the
learningMode
parameter of
imaqLearnPattern2()
to specify which type of learning mode to use.
The learning process is usually time intensive because the algorithm
attempts to find the optimum features of the template for the particular
matching process. The learning mode you choose also affects the speed of
the learning process. Learning the template for shift-invariant matching is
faster than learning for rotation-invariant matching. You can also save time
by training the pattern matching algorithm offline, and then saving the
template image with
imaqWriteVisionFile()
.
Defining a Search Area
Two equally important factors define the success of a pattern matching
algorithm: accuracy and speed. You can define a search area to reduce
ambiguity in the search process. For example, if your image has multiple
instances of a pattern and only one of them is required for the inspection
task, the presence of additional instances of the pattern can produce
incorrect results. To avoid this, reduce the search area so that only the
desired pattern lies within the search area.
The time required to locate a pattern in an image depends on both the
template size and the search area. By reducing the search area or increasing
the template size, you can reduce the required search time. Increasing the
template size can improve the search time, but doing so reduces match
accuracy if the larger template includes an excess of background
information.
In many inspection applications, you have general information about the
location of the fiducial. Use this information to define a search area. For
example, in a typical component placement application, each printed
circuit board (PCB) being tested may not be placed in the same location
with the same orientation. The location of the PCB in various images can
move and rotate within a known range of values, as illustrated in
Figure 5-11. Figure 5-11a shows the template used to locate the PCB in the
image. Figure 5-11b shows an image containing a PCB with a fiducial you
want to locate. Notice the search area around the fiducial. If you know
before the matching process begins that the PCB can shift or rotate in the
image within a fixed range, then you can limit the search for the fiducial to
a small region of the image. Figure 5-11c and Figure 5-11d show examples
of a shifted fiducial and a rotated fiducial respectively.