SetMatchOptions Method

NI Vision for Visual Basic

SetMatchOptions Method

Syntax

CWIMAQMultipleGeometricTemplate.SetMatchOptions Label, MatchOptions

Purpose

Sets the match options for the template corresponding to the specified label.

Parameters

Label As String

The label that identifies the template for which you are setting the match options.

MatchOptions As CWIMAQMatchGeometricPatternOptions

The match options.

Example

Dim MultipleTemplate As New CWIMAQMultipleGeometricTemplate

Private Sub Learn_Click()
    Dim Template1 As New CWIMAQImage
    Dim Template1MatchOptions As New CWIMAQMatchGeometricPatternOptions
    Dim Template2 As New CWIMAQImage
    Dim Template2MatchOptions As New CWIMAQMatchGeometricPatternOptions
    
    ' Read the templates
    CWIMAQVision1.ReadImageAndVisionInfo Template1, Template1Path
    CWIMAQVision1.ReadImageAndVisionInfo Template2, Template2Path
    
    ' Initialize the match options
    
    ' Add the templates to the multiple template and 
    ' set the match options
    MultipleTemplate.AddTemplate Template1, "Template 1"
    MultipleTemplate.SetMatchOptions "Template 1", Template1MatchOptions
    
    MultipleTemplate.AddTemplate Template2, "Template 2"
    MultipleTemplate.SetMatchOptions "Template 2", Template2MatchOptions
    
    ' Learn the multiple template
    CWIMAQVision1.LearnMultipleGeometricPatterns MultipleTemplate
End Sub

Private Sub Match_Click()
    Dim Target As New CWIMAQImage
    Dim Report As New CWIMAQGeometricPatternMatchReport
            
    ' Read the target image
    CWIMAQVision1.ReadImage Target, TargetPath
    
    ' Match the multiple template to the target
    CWIMAQVision1.MatchMultipleGeometricPatterns Target, _
                                                 MultipleTemplate, _
                                                 Report    
End Sub