CPU-first template matching library for grayscale images
Project description
corrmatch-py
Python bindings for corrmatch - CPU-first template matching library.
Installation
From source (development)
# Install maturin
pip install maturin
# Build and install in development mode
cd corrmatch-py
maturin develop
# Or build a release wheel
maturin build --release
pip install target/wheels/corrmatch-*.whl
Usage
Quick one-shot matching
import numpy as np
import corrmatch
# Load your images as numpy arrays (2D uint8)
image = np.array(...) # shape: (height, width)
template = np.array(...) # shape: (height, width)
# Simple matching (translation only)
result = corrmatch.match_template(image, template)
print(f"Found at ({result.x}, {result.y}) with score {result.score}")
# With rotation
result = corrmatch.match_template(image, template, rotation="enabled")
print(f"Found at ({result.x}, {result.y}), angle={result.angle_deg}deg, score={result.score}")
Efficient repeated matching
For matching the same template against multiple images:
import corrmatch
# Create and compile template once
tpl = corrmatch.Template(template_array)
compiled = tpl.compile() # With rotation support
# Or: compiled = tpl.compile_no_rotation() # Faster, no rotation
# Create matcher
matcher = compiled.matcher()
# Match against multiple images
for image in images:
result = matcher.match_image(image)
# Or: results = matcher.match_topk(image, k=5) # Top 5 matches
Configuration
# Compile config (rotation parameters)
compile_cfg = corrmatch.CompileConfig(
max_levels=6, # Pyramid levels
coarse_step_deg=10.0, # Initial angle step
min_step_deg=0.5, # Finest angle step
fill_value=0, # Fill for rotated edges
)
compiled = tpl.compile(compile_cfg)
# Match config
match_cfg = corrmatch.MatchConfig(
metric="zncc", # "zncc" or "ssd"
rotation="enabled", # "enabled" or "disabled"
parallel=True, # Use rayon parallelism
beam_width=8, # Candidates per level
nms_radius=6, # Non-maximum suppression radius
)
matcher = compiled.matcher(match_cfg)
Loading from files
# Load template from image file
tpl = corrmatch.Template.from_file("template.png")
Visualization (matplotlib)
CorrMatch includes a small visualization helper to inspect results in an interactive matplotlib window (rotated detection frame + template + matched patch + deskew + diff).
Install extra dependencies:
pip install -e ".[viz]"
Run from Python:
import corrmatch
import corrmatch.viz as viz
match_cfg = corrmatch.MatchConfig(rotation="enabled", metric="zncc")
fig, matches = viz.match_and_show(image, template, topk=5, match_cfg=match_cfg)
Or as a CLI:
corrmatch-viz --image image.png --template template.png --rotation enabled --topk 5
Angle convention: positive angles are clockwise (x right, y down).
API Reference
Classes
Template: Grayscale template imageCompiledTemplate: Pre-compiled template with pyramidsMatcher: Template matcher for coarse-to-fine searchMatch: Match result with x, y, angle_deg, scoreCompileConfig: Template compilation settingsMatchConfig: Matching parameters
Functions
match_template(image, template, ...): One-shot matching
Building
Requires:
- Rust toolchain (1.88+)
- Python 3.11+
- maturin (
pip install maturin)
cd corrmatch-py
PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 maturin develop
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file corrmatch-0.2.0.tar.gz.
File metadata
- Download URL: corrmatch-0.2.0.tar.gz
- Upload date:
- Size: 88.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29fb94cd01d9fb4cb15f306d7430a1bc192bf83e75c6fcfaf714b8fa9a6faea3
|
|
| MD5 |
bb73ab5e5b4039cc1bd38aa8b3a02cae
|
|
| BLAKE2b-256 |
da4b63e4df2ba14899437fbe276f7e1884bb12f2ee1cbfcdc1232a5bc55a3ca4
|
Provenance
The following attestation bundles were made for corrmatch-0.2.0.tar.gz:
Publisher:
release-pypi.yml on VitalyVorobyev/corrmatch-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corrmatch-0.2.0.tar.gz -
Subject digest:
29fb94cd01d9fb4cb15f306d7430a1bc192bf83e75c6fcfaf714b8fa9a6faea3 - Sigstore transparency entry: 1309272459
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/corrmatch-rs@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Trigger Event:
push
-
Statement type:
File details
Details for the file corrmatch-0.2.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: corrmatch-0.2.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 563.4 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a0537e6eca78f371a3e89bdf7928af86c041810c16d1008c17dbda2f1b7ad0e
|
|
| MD5 |
0ea5bd91a3a8a37a43f34982d2f89f6d
|
|
| BLAKE2b-256 |
17f7224ab97ee6685dc8bef4e37997529335c63f91d07ae99171f2ebf0e40155
|
Provenance
The following attestation bundles were made for corrmatch-0.2.0-cp310-abi3-win_amd64.whl:
Publisher:
release-pypi.yml on VitalyVorobyev/corrmatch-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corrmatch-0.2.0-cp310-abi3-win_amd64.whl -
Subject digest:
9a0537e6eca78f371a3e89bdf7928af86c041810c16d1008c17dbda2f1b7ad0e - Sigstore transparency entry: 1309272708
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/corrmatch-rs@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Trigger Event:
push
-
Statement type:
File details
Details for the file corrmatch-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: corrmatch-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 804.8 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b470144299bb61beaa4bba4de28208ad295e06cd47e401768a6cc9287a91f4f
|
|
| MD5 |
345b6601f0d65a380544bc5e18c6bdc8
|
|
| BLAKE2b-256 |
903f3f89a4d1bf3906c0f581dd8b309b35e5cb116ca8cfeda94521e7636f57cf
|
Provenance
The following attestation bundles were made for corrmatch-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-pypi.yml on VitalyVorobyev/corrmatch-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corrmatch-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
5b470144299bb61beaa4bba4de28208ad295e06cd47e401768a6cc9287a91f4f - Sigstore transparency entry: 1309272632
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/corrmatch-rs@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Trigger Event:
push
-
Statement type:
File details
Details for the file corrmatch-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: corrmatch-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 696.8 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2802994d6a3b4ed408606bcd5b52adfef42c9de340a475a708fde3382b32bf1f
|
|
| MD5 |
0e4cd4864f7c2add025314e2c791f2e8
|
|
| BLAKE2b-256 |
9f6f9f04831bbc6cad5ca5da47d42eaa8d8c816307eb779d61ba75cf5456bd24
|
Provenance
The following attestation bundles were made for corrmatch-0.2.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release-pypi.yml on VitalyVorobyev/corrmatch-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corrmatch-0.2.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
2802994d6a3b4ed408606bcd5b52adfef42c9de340a475a708fde3382b32bf1f - Sigstore transparency entry: 1309272546
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/corrmatch-rs@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@0b138485f22269be7f2fa9fd7e949d5e316ec696 -
Trigger Event:
push
-
Statement type: