waldo-lib
v2.0.4
Published
Javascript library for fast and simple template matching without weird opencv bindings
Downloads
321
Maintainers
Readme
waldo-lib
Javascript library for fast and simple template matching without weird opencv bindings!
What is template matching?
"Template matching is a technique in digital image processing for finding small parts of an image which match a template image." - wikipedia.org
Quickstart
$ npm install waldo-lib
import { Waldo, WaldoImageData, Match } from 'waldo-lib'
const waldo = new Waldo()
const image: WaldoImageData = {
data: Uint8ClampedArray.from([
0,0,0,255, 0,0,0,255, 0,0,0,255,
0,0,0,255, 255,255,255,255, 0,0,0,255,
0,0,0,255, 0,0,0,255, 0,0,0,255
]),
width: 3,
height: 3
}
const template: WaldoImageData = {
data: Uint8ClampedArray.from([
0,0,0,255, 0,0,0,255,
0,0,0,255, 255,255,255,255
]),
width: 2,
height: 2
}
const match = waldo.highestSimilarity(image, template)
console.log(match)
/*
{
location: { x: 1, y: 1 },
similarity: 1, // Value goes from 0 to 1
}
*/
How to load in ImageData
The libary is designed to work with data in the format used by the Canvas Web API. For now just look at guides for loading that.
Docs
The full API Documentation can be found under https://tinkertoe.github.io/waldo-lib