MatchTemplateAndEvaluate
Match a template image with every location in the source image 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:
HRESULT MatchTemplateAndEvaluate(
HRESULT hrPrev,
ITcVnImage* ipSrcImage,
ITcVnImage* ipTemplateImage,
ITcVnContainer*& ipMatches,
float fMatchThreshold,
ETcVnTemplateMatchMethod eMatchMethod = TMM_CCORR_NORMED,
ITcVnImage* ipTemplateMask = nullptr,
float fScaleFactor = 1,
ETcVnInterpolationType eInterpolationType = IT_BILINEAR,
ITcVnContainer** pipMatchValues = nullptr
)
Parameters
Name |
Type |
Default |
Description |
---|---|---|---|
hrPrev |
|
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) | |
ipSrcImage |
|
Source image (USINT or REAL, 1 or 3 channels) | |
ipTemplateImage |
|
Template image (same type as ipSrcImage, smaller width and height) | |
ipMatches |
|
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 |
float |
|
Threshold to separate relevant from irrelevant matches (0..1 for NORMED methods, otherwise dependent on template size and content. To find a suitable value, you could evaluate some sample result images of F_VN_MatchTemplateExp.) |
eMatchMethod |
TMM_CCORR_NORMED |
Specifies the template match method | |
ipTemplateMask |
nullptr |
Optional mask for ipTemplateImage (same type and size as ipTemplateImage) | |
fScaleFactor |
float |
1 |
Factor (0..1] to reduce source and template image width and height for better performance (but less accuracy!) |
eInterpolationType |
IT_BILINEAR |
Image resize interpolation type (only used if fScaleFactor != 1, TCVN_IT_BILINEAR recommended for most cases) | |
pipMatchValues |
nullptr |
Optionally returns the matching values (ContainerType_Vector_REAL, same size and sort order as ipMatches. Set to 0 if not required.) |
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 |