F_VN_MatchTemplateAndEvaluate

F_VN_MatchTemplateAndEvaluate 1:

Match a template image with every location in the source image (using the TCVN_TMM_CCORR_NORMED method) and evaluate the comparison results. Returns a sorted list of possible matches (best match first).
Can use available TwinCAT Job Tasks for executing parallel code regions.
Can return partial results when canceled by Watchdog.

Syntax

Definition:

FUNCTION F_VN_MatchTemplateAndEvaluate : HRESULT
VAR_INPUT
    ipSrcImage      : ITcVnImage;
    ipTemplateImage : ITcVnImage;
    ipMatches       : Reference To ITcVnContainer;
    fMatchThreshold : REAL;
    hrPrev          : HRESULT;
END_VAR

F_VN_MatchTemplateAndEvaluate 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image (USINT or REAL, 1 or 3 channels)

ipTemplateImage

ITcVnImage

Template image (same type as ipSrcImage, smaller width and height)

ipMatches

Reference To ITcVnContainer

Returns the matching positions (ContainerType_Vector_TcVnPoint2_DINT, where each element represents the top-left corner of ipTemplateImage) in ipSrcImage, sorted by relevance (best match first)

fMatchThreshold

REAL

Threshold to separate relevant from irrelevant matches (0..1, 1.0 would be a perfect match. To find a suitable value, you could evaluate some sample result images of F_VN_MatchTemplate.)

hrPrev

HRESULT

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

F_VN_MatchTemplateAndEvaluate 3: 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