Principle:A9T9 RPA Template Matching
| Knowledge Sources | |
|---|---|
| Domains | Computer_Vision, Image_Search |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Mechanism for locating a template (pattern) image within a larger scene image by computing normalized cross-correlation across positions and scale bands.
Description
Template Matching is the computer-vision technique of finding instances of a small pattern image within a larger target image (the screenshot). The Ui.Vision vision2 WASM engine uses zero-mean normalized cross-correlation (NCC), which prevents flat regions (uniform-colored areas) from false-positive matching — a weakness of plain cross-correlation.
The engine supports:
- DPI-prior scale band: the `patternScale` parameter provides a prior on the expected scale ratio between the pattern and the scene, narrowing the search space and improving accuracy.
- Search area cropping: the search can be restricted to a sub-region of the screenshot for performance and accuracy.
- Size variation: optional allowance for moderate size differences between the pattern and the scene occurrence.
- Confidence scoring: each match region returns a similarity score (0.0-1.0); the caller filters by a minimum similarity threshold.
The matching runs in a Web Worker with the Rust vision-core WASM module, communicating via a message protocol (init/job messages with job IDs for promise correlation).
Usage
Use this principle when a visual automation system needs to locate on-screen UI elements by their appearance rather than by DOM structure — essential for desktop automation, canvas-based applications, and dynamic web content.
Theoretical Basis
Zero-mean normalized cross-correlation at position :
Where is the template, is the image region, and are their means. The result is in , mapped to for the similarity score.