feat: built-in lodash.js

close #281
This commit is contained in:
hyb1996
2018-02-01 16:34:40 +08:00
parent a06fca1971
commit ee638e3d6b
6 changed files with 75 additions and 14 deletions

View File

@@ -101,7 +101,7 @@ module.exports = function(__runtime__, scope){
}
var weakThreshold = options.weakThreshold || 0.7;
if(options.region){
return rtImages.findImage(img, template, weakThreshold, threshold, buildRegion(options, img), maxLevel);
return rtImages.findImage(img, template, weakThreshold, threshold, buildRegion(options.region, img), maxLevel);
}else{
return rtImages.findImage(img, template, weakThreshold, threshold, null, maxLevel);
}
@@ -140,11 +140,12 @@ module.exports = function(__runtime__, scope){
}
function buildRegion(region, img){
var x = region[0] || 0;
var y = region[1] || 0;
var width = region[2] || (img.getWidth() - x);
var height = region[3] || (img.getHeight() - y);
return new org.opencv.core.Rect(x, y, width, height);
var x = region[0] === undefined ? 0 : region[0];
var y = region[1] === undefined ? 0 : region[1];
var width = region[2] === undefined ? img.getWidth() - x : region[2];
var height = region[3] === undefined ? (img.getHeight() - y) : region[3];
var r = new org.opencv.core.Rect(x, y, width, height);
return r;
}
function parseColor(color){