Skip to main content

Crate corrmatch

Crate corrmatch 

Source
Expand description

CorrMatch is a CPU-first template matching library for grayscale images.

It provides a coarse-to-fine matcher with optional rotation search and two metrics: ZNCC and SSD. The primary entry points are Template, CompiledTemplate, and Matcher.

§Quick start

use corrmatch::{
    CompileConfig, MatchConfig, Matcher, RotationMode, Template, ImageView,
};

let template = Template::new(tpl, tw, th)?;
let compiled = template.compile(CompileConfig::default())?;
let matcher = Matcher::new(compiled).with_config(MatchConfig {
    rotation: RotationMode::Enabled,
    ..MatchConfig::default()
});
let image_view = ImageView::from_slice(image, width, height)?;
matcher.match_image(image_view)

§Concepts

  • Template: owned template pixels.
  • CompiledTemplate: precomputed template pyramid and (optionally) angle banks.
  • Matcher: runs the coarse-to-fine search and returns the best match.
  • CompiledTemplate::compile_unrotated: lightweight assets for translation-only matching.

§Data model

  • Images and templates are grayscale u8 buffers in row-major order.
  • ImageView supports explicit row stride; results report top-left coordinates at level 0.
  • Scores: ZNCC in roughly [-1, 1], SSD reported as negative SSE (higher is better).

§Determinism

Matching is deterministic; enabling rayon via MatchConfig.parallel keeps results stable.

§Feature flags

  • rayon: parallel search execution.
  • simd: SIMD-accelerated kernels (currently: unmasked translation-only path).
  • image-io: file I/O helpers via the image crate.

§Low-level API

Advanced building blocks are available under corrmatch::lowlevel.

§CLI

A JSON-driven CLI lives in the corrmatch-cli workspace crate.

Modules§

lowlevel
Low-level building blocks for custom matching pipelines.

Structs§

CompileConfig
Configuration for compiling template assets with rotation support.
CompileConfigNoRot
Configuration for compiling template assets without rotation support.
ImagePyramid
Owned image pyramid built from a base level.
ImageView
Borrowed 2D image view with an explicit stride.
Match
Match result for the finest pyramid level.
MatchConfig
Configuration for the coarse-to-fine matcher pipeline.
Matcher
Matcher that runs coarse-to-fine search using a compiled template.
OwnedImage
Owned contiguous grayscale image buffer.
Template
Owned template image in contiguous grayscale format.

Enums§

CompiledTemplate
Compiled template assets for rotated or unrotated matching.
CorrMatchError
Errors that can occur when running corrmatch operations.
Metric
Matching metric selector.
RotationMode
Controls whether rotation is searched.

Type Aliases§

CorrMatchResult
Result alias for corrmatch operations.