waldo-lib
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

waldo-lib

npm version

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

Package Sidebar

Install

npm i waldo-lib

Weekly Downloads

1

Version

2.0.4

License

GPL-3.0-only

Unpacked Size

179 kB

Total Files

11

Last publish

Collaborators

  • tinkertoe