#gpu #image #computer-vision

template-matching

GPU-accelerated template matching

2 unstable releases

0.2.0 Jul 21, 2023
0.1.0 Jul 19, 2023

#905 in Images

Download history 4/week @ 2024-02-20 10/week @ 2024-02-27 1/week @ 2024-03-05 9/week @ 2024-03-12 3/week @ 2024-03-26 28/week @ 2024-04-02 35/week @ 2024-04-09

66 downloads per month

MIT license

78KB
452 lines

template-matching

Latest version Documentation MIT

GPU-accelerated template matching library for Rust. The crate is designed as a faster alternative to imageproc::template_matching.

Installation

[dependencies]
template-matching = { version = "0.1.0", features = ["image"] }

Usage

use template_matching::{find_extremes, match_template, MatchTemplateMethod, TemplateMatcher};

fn main() {
    // Load images and convert them to f32 grayscale
    let input_image = image::load_from_memory(include_bytes!("input.png")).unwrap().to_luma32f();
    let template_image = image::load_from_memory(include_bytes!("template.png")).unwrap().to_luma32f();

    let result = match_template(&input_image, &template_image, MatchTemplateMethod::SumOfSquaredDifferences);

    // Or alternatively you can create the matcher first
    let matcher = TemplateMatcher::new();
    let result = matcher.match_template(&input_image, &template_image, MatchTemplateMethod::SumOfSquaredDifferences);

    // Calculate min & max values
    let extremes = find_extremes(&result);
}

Dependencies

~15–49MB
~587K SLoC