National Instruments IMAQTM 用户手册

下载
页码 121
Chapter 5
Performing Machine Vision Tasks
5-26
ni.com
Does not always require the location with sub-pixel accuracy
Does not require shape information for the region
Complete the following steps to find features in an image using color 
location:
1.
Define a reference pattern in the form of a template image.
2.
Use the reference pattern to train the color location algorithm with 
CWIMAQVision.LearnColorPattern
.
3.
Define an image or an area of an image as the search area. A small 
search area reduces the time to find the features.
4.
Set 
CWIMAQMatchColorPatternOptions.FeatureMode
 to 
cwimaqFeatureColorInformation
.
5.
Set the tolerances and parameters to specify how the method operates 
at run time using 
CWIMAQMatchColorPatternOptions
.
6.
Use 
CWIMAQVision.MatchColorPattern
 to test the color location 
algorithm on test images.
7.
Verify the results using a ranking method.
Use 
CWIMAQVision.WriteImageAndVisionInfo
 to save the template 
image.
Convert Pixel Coordinates to Real-World Coordinates
The measurement points you located with edge detection and pattern 
matching are in pixel coordinates. If you need to make measurements using 
real-world units, use 
CWIMAQVision.ConvertPixelToRealWorldCoordinates
 to convert 
the pixel coordinates into real-world units.
Make Measurements
You can make different types of measurements either directly from the 
image or from points that you detect in the image.
Distance Measurements
Use the following methods to make distance measurements for the 
inspection application.
Clamp methods measure the separation between two edges in a rectangular 
search region. First, clamp methods detect points along the two edges using