LearnMultipleGeometricPatterns Method

NI Vision for Visual Basic

LearnMultipleGeometricPatterns Method

Syntax

CWIMAQVision.LearnMultipleGeometricPatterns MultipleGeometricTemplate

Return Type

Long

Purpose

Learns the multiple geometric template.

Parameters

MultipleGeometricTemplate As CWIMAQMultipleGeometricTemplate

The template to learn.

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