Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:A9T9 RPA Template Matching

From Leeroopedia
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 (u,v):

NCC(u,v)=∑x,y(Tx,y−T¯)(Iu+x,v+y−I¯u,v)∑x,y(Tx,y−T¯)2⋅∑x,y(Iu+x,v+y−I¯u,v)2

Where T is the template, I is the image region, T¯ and I¯u,v are their means. The result is in [−1,1], mapped to [0,1] for the similarity score.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment