Provides methods built upon opencv.
The following modules are included.
Wrapper for
cv::imread
.
Finds positions of template matches in the source image. Can supply multiple template images.
cv::matchTemplate
.Promise
will be returned;var MonkeyOpencv = require('monkey-opencv').MonkeyOpencv;
var Constants = require ('monkey-opencv').Constants;
var fs = require ('fs');
MonkeyOpencv.findSubImage({
source: 'source.png',
templates: ['template.png'],
matchPercent: 70,
maximumMatches: 1,
downPyramids: 1,
searchExpansion: 15,
method: Constants.TM_CCORR_NORMED,
}, function(matches){
console.log('Matches with callback: ',matches[0].position);
})
// Example with Matrix as a template
MonkeyOpencv.readImage('template.png', function(tmpl) {
MonkeyOpencv.findSubImage({
source: 'source.png',
templates: [tmpl, 'invalid_template.png'],
})
.then(function(matches){
console.log('Matches with Promise: ', matches[0].position);
}, function(err){});
});
});
// Example with Buffer as a template
var source = fs.readFileSync('template.png');
MonkeyOpencv.findSubImage({
source: source,
templates: ['template.png', 'invalid_template.png'],
})
.then(function(matches){
console.log('Matches with Promise: ', matches[0].position);
}, function(err){});
});
npm install --save monkey-opencv
npm install node-gyp node-pre-gyp -g
XCode
Install window build tools. Refer to https://github.com/nodejs/node-gyp.
npm install --global --production windows-build-tools