https://docs.adaptive-vision.com/current/studio/machine_vision_guide/TemplateMatching.html
模板匹配 Template Matching
简单模板匹配 Naive Template Matching
基本原理 NCC(Normalized Cross-Correlation)
模板图像和输入图片匹配的结果也是一种图像 Template Correlation Image.
2.1 两种方法, 找出相关性最大的点.
2.2 通常会用到两个Filter: ImageLocalMaxima, ImageCorrelationImage缺点
基于灰度匹配, 基于边缘匹配 Grayscale-based Matching, Edge-based Matching
选择合适的金字塔参数 (值越大, 原始图被"提取"的越小)
基于灰度匹配时, 目标旋转也可被找到, 位移和角度可以兼顾.
基于边缘匹配
AVS提供的实现 (Model + Match)
交互式创建 EdgeModel, GrayMdel, Golden Template Model(CompareGoldenTemplate_Intensity and in CompareGoldenTemplate_Edges)
动态创建Model, 再做match.
CreateGrayModle + LocateObjects;
CreateEdgeModel + LocateObjects
- 参数
3.1 inPyramidHeight (值越大, 原始图被"提取"的越小)
3.2 inMinAngel, inMaxAngle
3.3 inEdgeMagnitudeThreshold 值越小, 被检测的边缘细节越多, 配合 inEdgeHysteresis
Note:
The SAD (Sum of Absolute Differences) method can be significantly slower than NCC (Normalized Cross-Correlation) method. Moreover, it is not illumination-invariant, as it is required in most applications. Thus, it is highly recommended to use the latter, NCC method instead.
大部分的情况下, 边缘匹配都比灰度匹配好用.
来源:https://www.cnblogs.com/onecrazystone/p/12306150.html