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

Metadata

Release files for corrmatch 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for corrmatch 0.2.5
File Size Uploaded
corrmatch-0.2.5.tar.gz 88.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for corrmatch 0.2.5
File Interpreter ABI Platform
corrmatch-0.2.5-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
corrmatch-0.2.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
corrmatch-0.2.5-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 2.2 MB

Release files / corrmatch-0.2.5.tar.gz

Download URL corrmatch-0.2.5.tar.gz
Size 88.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9ae84d90c1d2a565ddc4e322d33da5ca23c2a585369a708b3f5d38c740720e12
BLAKE2b-256 checksum
How to use checksums
aeb23f571a39e7d3a7fa5b4924b83d7066f6352cafc92ec545655aa9d868bab2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release files / corrmatch-0.2.5-cp310-abi3-win_amd64.whl

Download URL corrmatch-0.2.5-cp310-abi3-win_amd64.whl
Size 581.2 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
644b85f6650e2d0b1ca756b6580b46b4a83305ad0127b50eebcd11cf4cd2b53e
BLAKE2b-256 checksum
How to use checksums
26585edaf054e13af207db459f718fdabf4adfc8d0c0fb0259101cda159b0676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release files / corrmatch-0.2.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL corrmatch-0.2.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 805.3 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0c56a299f8b6842b541cbcf83562cfb5a961ca00179e044295773a5f72e52d7e
BLAKE2b-256 checksum
How to use checksums
479277a75053301df6f859b8ee50892718b91e3ed8f0e5c50c82bd5e71e0b132
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release files / corrmatch-0.2.5-cp310-abi3-macosx_11_0_arm64.whl

Download URL corrmatch-0.2.5-cp310-abi3-macosx_11_0_arm64.whl
Size 707.1 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5d8fa0e0dd762794582900d04ac2656ad051ccfb09c3316065ba28820684d543
BLAKE2b-256 checksum
How to use checksums
e27b5c661b9e704ce59cf86c86a2b113f1c71fc7c4430ddbcd843f971dc6c8a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.5 This release

4 release files

0.2.4

4 release files

0.2.3

4 release files

0.2.1

4 release files

0.2.0

4 release 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