https://github.com/urholaukkarinen/template-matching
GPU-accelerated template matching for Rust
https://github.com/urholaukkarinen/template-matching
computer-vision gpu image-recognition rust template-matching
Last synced: about 2 months ago
JSON representation
GPU-accelerated template matching for Rust
- Host: GitHub
- URL: https://github.com/urholaukkarinen/template-matching
- Owner: urholaukkarinen
- License: mit
- Created: 2023-07-19T19:08:37.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-23T13:14:00.000Z (almost 2 years ago)
- Last Synced: 2024-04-29T00:23:21.997Z (about 1 year ago)
- Topics: computer-vision, gpu, image-recognition, rust, template-matching
- Language: Rust
- Homepage:
- Size: 65.4 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# template-matching
[](https://crates.io/crates/template-matching)
[](https://docs.rs/template-matching)
GPU-accelerated template matching library for Rust. The crate is designed as a faster alternative to [imageproc::template_matching](https://docs.rs/imageproc/latest/imageproc/template_matching/index.html).
## Installation
```bash
[dependencies]
template-matching = { version = "0.2.0", features = ["image"] }
```## Usage
```rust
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 mut matcher = TemplateMatcher::new();
matcher.match_template(&input_image, &template_image, MatchTemplateMethod::SumOfSquaredDifferences);
let result = matcher.wait_for_result().unwrap();// Calculate min & max values
let extremes = find_extremes(&result);
}
```