MatchMultipleGeometricPatterns Method

NI Vision for Visual Basic

MatchMultipleGeometricPatterns Method

Syntax

CWIMAQVision.MatchMultipleGeometricPatterns SearchImage, MultipleGeometricTemplate, GeometricPatternMatchReport [, Regions]

Return Type

Long

Purpose

Searches for the templates that are part of the multiple geometric template in the target image.

Remarks

Use one of the following methods to obtain the template image you want to use with this method:

  1. Load a previously saved multiple geometric template with CWIMAQVision.ReadMultipleGeometricTemplateFile.
  2. Use CWIMAQVision.LearnMultipleGeometricPatterns to learn a multiple geometric template.
  3. Use this method with U8 images.

    Parameters

    SearchImage As CWIMAQImage

    The image in which the multiple template images are to be located.

    MultipleGeometricTemplate As CWIMAQMultipleGeometricTemplate

    The multiple template images to search for.

    GeometricPatternMatchReport As CWIMAQGeometricPatternMatchReport

    On return, a report containing information about each match found in the image.

    Regions As Variant

    [Optional] A CWIMAQRegions object that specifies the regions within an image in which to search for the template. The CWIMAQRegions object must contain exactly one rectangle or one rotated rectangle region. Do not supply this parameter if you want the entire image to be examined.

    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