Skip to main content

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 image
  • CompiledTemplate: Pre-compiled template with pyramids
  • Matcher: Template matcher for coarse-to-fine search
  • Match: Match result with x, y, angle_deg, score
  • CompileConfig: Template compilation settings
  • MatchConfig: 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

corrmatch-0.2.1.tar.gz (88.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

corrmatch-0.2.1-cp310-abi3-win_amd64.whl (563.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

corrmatch-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (786.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

corrmatch-0.2.1-cp310-abi3-macosx_11_0_arm64.whl (690.5 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file corrmatch-0.2.1.tar.gz.

File metadata

  • Download URL: corrmatch-0.2.1.tar.gz
  • Upload date:
  • Size: 88.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for corrmatch-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c9e4504acd7ca4ad19f91ba9aa20c26491d2e89cb0e90c60ce4afeb50770e075
MD5 5b89b6a03b09177813932b1a9d265ab3
BLAKE2b-256 f2458a0510d4bbd427372fc74292014dfd72027b91db37f0f3ecd1559fda7fee

See more details on using hashes here.

Provenance

The following attestation bundles were made for corrmatch-0.2.1.tar.gz:

Publisher: release-pypi.yml on VitalyVorobyev/corrmatch-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file corrmatch-0.2.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: corrmatch-0.2.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 563.7 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for corrmatch-0.2.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2f4d87fdc1a922f094e85898c7b80fcde78fae88489e7315d2979f6e4736c45e
MD5 72170e4f4f1ea68f057ab66130e7192b
BLAKE2b-256 e3ea8d8abbe0719e4351418c73e8b5658accb06b712c7484db83640eeaed76ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for corrmatch-0.2.1-cp310-abi3-win_amd64.whl:

Publisher: release-pypi.yml on VitalyVorobyev/corrmatch-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file corrmatch-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for corrmatch-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea1de253ce3cd308711ba533c691ad2e4e1660fbdf30ed547417f8d99501080e
MD5 d41c6189ea1dd02d3736e6f5f1a3febd
BLAKE2b-256 45d6ba42d56782e7e992e558009e2f49b448819aa75459d1e68a7873bb07b5e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for corrmatch-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pypi.yml on VitalyVorobyev/corrmatch-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file corrmatch-0.2.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for corrmatch-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7e8163b9abf28eea55cdbdb507f0625058bc7aef9c08540ac675f261c62ea16
MD5 6c5b09cc24bdd4a3e02a4ee753b24ce7
BLAKE2b-256 20fc4755a6fdd18c1f50296501e099d77bb0ab1430943f38e4d95ddd9fca3a42

See more details on using hashes here.

Provenance

The following attestation bundles were made for corrmatch-0.2.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on VitalyVorobyev/corrmatch-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.5

4 files

0.2.4

4 files

0.2.3

4 files

This release

0.2.1 This release

4 files

0.2.0

4 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page