MatchContours1vsN

Compare a reference contour with multiple other contours using the Hu moment invariants (and optionally further aspects). Returns a sorted list of best matches.

Syntax

Definition:

HRESULT MatchContours1vsN(
    HRESULT                            hrPrev,
    ITcVnContainer*                    ipRefContour,
    ITcVnContainer*                    ipContours,
    ITcVnContainer*&                   ipMatchIndexes,
    ITcVnContainer*&                   ipDissimilarities,
    double                             fDissimilarityThreshold,
    ETcVnContoursMatchComparisonMethod eComparisonMethod,
    double                             fAreaFactor = 0,
    double                             fAbsPositionFactor = 0
)

Parameters

Name

Type

Default

Description

hrPrev

HRESULT

 

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

ipRefContour

ITcVnContainer*

 

Reference contour (ContainerType_Vector_TcVnPoint2_DINT or ContainerType_Vector_TcVnPoint2_REAL; The elements of this container are the points of the contour)

ipContours

ITcVnContainer*

 

Collection of multiple contours (CTcVnContainer_Vector_Vector_TcVnPoint2_DINT)

ipMatchIndexes

ITcVnContainer*&

 

Returns the indexes of the best matches (CTcVnContainer_Vector_ULINT; sorted, first element is best match, i.e. has lowest dissimilarity)

ipDissimilarities

ITcVnContainer*&

 

Returns the computed dissimilarities of the best matches (CTcVnContainer_Vector_LREAL; Optional, set to 0 if not required; sorted corresponding to ipMatchIndexes)

fDissimilarityThreshold

double

 

Neglect irrelevant matches, i.e. dissimilarity > fDissimilarityThreshold

eComparisonMethod

ETcVnContoursMatchComparisonMethod

 

Method used for comparing the Hu moment invariants of the contours

fAreaFactor

double

0

If > 0, the relative area difference between contours is scaled by this factor and added to the computed dissimilarity

fAbsPositionFactor

double

0

If > 0, the absolute position difference between contours (i.e. the coordinates of the geometric contour centers) is scaled by this factor and added to the computed dissimilarity

MatchContours1vsN 1: Return value

HRESULT

Required License

TC3 Vision Matching

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision