Skip to content

Instantly share code, notes, and snippets.

@oskardahlberg
Created February 28, 2015 14:41
Show Gist options
  • Save oskardahlberg/a9bfd1916d923b765631 to your computer and use it in GitHub Desktop.
Save oskardahlberg/a9bfd1916d923b765631 to your computer and use it in GitHub Desktop.
templateMatches
Here is the implementation
https://github.com/peterbraden/node-opencv/blob/master/src/Matrix.cc#L1736
The argument preprocessing is bad, you should probably specify all.
var matchMatrix = sourceMatrix.matchTemplate(targetMatrix, 0 /* TM_SQDIFF */);
var matches = matchMatrix.templateMatches(
minProbability,
maxProbability,
limit,
ascending, // true/false, lower probability score is better, use for TM_SQDIFF/0 and TM_SQDIFF_NORMED/1
minXDistance,
minYDistance
);
// matches is now an array of matches sorted by probability
// each match has properties x, y and probability
// minXDistance and minYDistance is optionally used to filter out the best of neighbouring matches
// so if you dont want to find overlapping matches, set these to targetWidth/2 and targetHeight/2 as ints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment