diff --git a/beeld.config b/beeld.config index 0e62b4e..8804a88 100644 --- a/beeld.config +++ b/beeld.config @@ -42,7 +42,7 @@ tasks =[{}] "@@ROOT@@" = "'undefined' !== typeof self ? self : this" "@@MODULE@@" = "HAAR" - "@@VERSION@@" = "1.0.4" + "@@VERSION@@" = "1.0.5" @ diff --git a/build/haar-detector.js b/build/haar-detector.js index 0b5628c..2059912 100644 --- a/build/haar-detector.js +++ b/build/haar-detector.js @@ -4,7 +4,7 @@ * modified port of jViolaJones for Java (http://code.google.com/p/jviolajones/) and OpenCV for C++ (https://github.com/opencv/opencv) to JavaScript * * https://github.com/foo123/HAAR.js -* @version: 1.0.4 +* @version: 1.0.5 * * Supports parallel "map-reduce" computation both in browser and node using parallel.js library * https://github.com/adambom/parallel.js (included) @@ -28,7 +28,7 @@ else if ( !(name in root) ) /* Browser/WebWorker/.. */ * modified port of jViolaJones for Java (http://code.google.com/p/jviolajones/) and OpenCV for C++ (https://github.com/opencv/opencv) to JavaScript * * https://github.com/foo123/HAAR.js -* @version: 1.0.4 +* @version: 1.0.5 * * Supports parallel "map-reduce" computation both in browser and node using parallel.js library * https://github.com/adambom/parallel.js (included) @@ -37,7 +37,7 @@ else if ( !(name in root) ) /* Browser/WebWorker/.. */ "use strict"; // the export object -var HAAR = {VERSION : "1.0.4"}, Detector, Feature, proto = 'prototype', undef = undefined; +var HAAR = {VERSION : "1.0.5"}, Detector, Feature, proto = 'prototype', undef = undefined; var // typed arrays substitute Array32F = (typeof Float32Array !== "undefined") ? Float32Array : Array, @@ -421,8 +421,8 @@ function detectSingleStep(self) tyw = ysize*w; tys = ystep*w; startty = starty*tys; - xl = selw-xsize; - yl = selh-ysize; + xl = startx+selw-xsize; + yl = starty+selh-ysize; swh = xsize*ysize; inv_area = 1.0/swh; @@ -487,7 +487,7 @@ function detectSingleStep(self) if (feature.tilt) { // tilted rectangle feature, Lienhart et al. extension - for (kr = 0; kr < nb_rects; kr++) + for (kr = 0; kr < nb_rects; ++kr) { r = rects[kr]; @@ -948,7 +948,7 @@ Detector[proto] = { epsilon = (typeof epsilon == 'undefined') ? 0.2 : (+epsilon); doCannyPruning = (typeof doCannyPruning == 'undefined') ? false : (!!doCannyPruning); - maxScale = self.maxScale = Min(scaledSelection.width/sizex, scaledSelection.height/sizey); + maxScale = self.maxScale = Min(/*scaledSelection.*/width/sizex, /*scaledSelection.*/height/sizey); scale = self.scale = baseScale; self.min_neighbors = min_neighbors; self.scale_inc = scale_inc; @@ -1054,7 +1054,7 @@ Detector[proto] = { self.epsilon = (typeof epsilon == 'undefined') ? 0.2 : (+epsilon); self.doCannyPruning = (typeof doCannyPruning == 'undefined') ? false : (!!doCannyPruning); - maxScale = self.maxScale = Min(self.scaledSelection.width/sizex, self.scaledSelection.height/sizey); + maxScale = self.maxScale = Min(self/*.scaledSelection*/.width/sizex, self/*.scaledSelection*/.height/sizey); self.scale = baseScale; self.min_neighbors = min_neighbors; self.scale_inc = scale_inc; diff --git a/build/haar-detector.min.js b/build/haar-detector.min.js index c641c3e..0bead67 100644 --- a/build/haar-detector.min.js +++ b/build/haar-detector.min.js @@ -4,9 +4,9 @@ * modified port of jViolaJones for Java (http://code.google.com/p/jviolajones/) and OpenCV for C++ (https://github.com/opencv/opencv) to JavaScript * * https://github.com/foo123/HAAR.js -* @version: 1.0.4 +* @version: 1.0.5 * * Supports parallel "map-reduce" computation both in browser and node using parallel.js library * https://github.com/adambom/parallel.js (included) * -**/!function(t,e,n){"use strict";"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[e]=n.call(t)):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(e)?define(e,["module"],function(e){return n.moduleUri=e.uri,n.call(t)}):e in t||(t[e]=n.call(t)||1)&&"function"==typeof define&&define.amd&&define(function(){return t[e]})}("undefined"!=typeof self?self:this,"HAAR",function(){"use strict";var e,R,t={VERSION:"1.0.4"},n="prototype",i=void 0,p="undefined"!=typeof Float32Array?Float32Array:Array,v="undefined"!=typeof Uint8Array?Uint8Array:Array,ye=Math,m=ye.abs,S=ye.max,A=ye.min,h=(ye.floor,ye.round),l=(ye.sqrt,Array[n].slice);function o(e,t,n){for(var i,l,a,r,h,o,s=e.length,u=new Array(s),c=[],d=0,g=!1,f=0;f>>14,f+=r&=255,i+=r*r,o[d]=r,s[d]=f,u[d]=i,c[d]=r,++d,g+=4;for(a=1,g=(d=t)<<2,f=i=l=0;g>>14,f+=r&=255,i+=r*r,o[d]=r,s[d]=s[d-t]+f,u[d]=u[d-t]+i,c[d]=c[d+1-t]+(r+o[d-t])+(1>>14&255)>>>0;for(x=1;x+1=e.x-n&&this.y>=e.y-t&&this.x+this.width<=e.x+e.width+n&&this.y+this.height<=e.y+e.height+t},contains:function(e,t){return e.inside(this,null==t?.1:t)},equals:function(e,t){t=(t=(t=null==t?.2:t)<0?0:t)*(A(this.width,e.width)+A(this.height,e.height))*.5;return m(this.x-e.x)<=t&&m(this.y-e.y)<=t&&m(this.x+this.width-e.x-e.width)<=t&&m(this.y+this.height-e.y-e.height)<=t},clone:function(){var e=this,t=new R;return t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height,t.index=e.index,t.area=e.area,t.isInside=e.isInside,t},copy:function(e){var t=this;return e&&e instanceof R&&(t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height,t.index=e.index,t.area=e.area,t.isInside=e.isInside),t},toString:function(){return["[ x:",this.x,"y:",this.y,"width:",this.width,"height:",this.height,"]"].join(" ")}},t}); \ No newline at end of file +**/!function(t,e,n){"use strict";"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[e]=n.call(t)):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(e)?define(e,["module"],function(e){return n.moduleUri=e.uri,n.call(t)}):e in t||(t[e]=n.call(t)||1)&&"function"==typeof define&&define.amd&&define(function(){return t[e]})}("undefined"!=typeof self?self:this,"HAAR",function(){"use strict";var e,R,t={VERSION:"1.0.5"},n="prototype",i=void 0,p="undefined"!=typeof Float32Array?Float32Array:Array,v="undefined"!=typeof Uint8Array?Uint8Array:Array,ye=Math,m=ye.abs,S=ye.max,A=ye.min,h=(ye.floor,ye.round),l=(ye.sqrt,Array[n].slice);function o(e,t,n){for(var i,l,a,r,h,o,u=e.length,s=new Array(u),c=[],d=0,g=!1,f=0;f>>14,f+=r&=255,i+=r*r,o[d]=r,u[d]=f,s[d]=i,c[d]=r,++d,g+=4;for(a=1,g=(d=t)<<2,f=i=l=0;g>>14,f+=r&=255,i+=r*r,o[d]=r,u[d]=u[d-t]+f,s[d]=s[d-t]+i,c[d]=c[d+1-t]+(r+o[d-t])+(1>>14&255)>>>0;for(x=1;x+1=e.x-n&&this.y>=e.y-t&&this.x+this.width<=e.x+e.width+n&&this.y+this.height<=e.y+e.height+t},contains:function(e,t){return e.inside(this,null==t?.1:t)},equals:function(e,t){t=(t=(t=null==t?.2:t)<0?0:t)*(A(this.width,e.width)+A(this.height,e.height))*.5;return m(this.x-e.x)<=t&&m(this.y-e.y)<=t&&m(this.x+this.width-e.x-e.width)<=t&&m(this.y+this.height-e.y-e.height)<=t},clone:function(){var e=this,t=new R;return t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height,t.index=e.index,t.area=e.area,t.isInside=e.isInside,t},copy:function(e){var t=this;return e&&e instanceof R&&(t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height,t.index=e.index,t.area=e.area,t.isInside=e.isInside),t},toString:function(){return["[ x:",this.x,"y:",this.y,"width:",this.width,"height:",this.height,"]"].join(" ")}},t}); \ No newline at end of file diff --git a/changelog.md b/changelog.md index 3b04f10..7f9f544 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ ### ChangeLog +__1.0.5__ +* fix detection with selected region + __1.0.4__ * better square root approximation in canny edges * update CanvasLite diff --git a/src/haar-detector.js b/src/haar-detector.js index 8e3d72c..d54f091 100644 --- a/src/haar-detector.js +++ b/src/haar-detector.js @@ -397,8 +397,8 @@ function detectSingleStep(self) tyw = ysize*w; tys = ystep*w; startty = starty*tys; - xl = selw-xsize; - yl = selh-ysize; + xl = startx+selw-xsize; + yl = starty+selh-ysize; swh = xsize*ysize; inv_area = 1.0/swh; @@ -463,7 +463,7 @@ function detectSingleStep(self) if (feature.tilt) { // tilted rectangle feature, Lienhart et al. extension - for (kr = 0; kr < nb_rects; kr++) + for (kr = 0; kr < nb_rects; ++kr) { r = rects[kr]; @@ -924,7 +924,7 @@ Detector[proto] = { epsilon = (typeof epsilon == 'undefined') ? 0.2 : (+epsilon); doCannyPruning = (typeof doCannyPruning == 'undefined') ? false : (!!doCannyPruning); - maxScale = self.maxScale = Min(scaledSelection.width/sizex, scaledSelection.height/sizey); + maxScale = self.maxScale = Min(/*scaledSelection.*/width/sizex, /*scaledSelection.*/height/sizey); scale = self.scale = baseScale; self.min_neighbors = min_neighbors; self.scale_inc = scale_inc; @@ -1030,7 +1030,7 @@ Detector[proto] = { self.epsilon = (typeof epsilon == 'undefined') ? 0.2 : (+epsilon); self.doCannyPruning = (typeof doCannyPruning == 'undefined') ? false : (!!doCannyPruning); - maxScale = self.maxScale = Min(self.scaledSelection.width/sizex, self.scaledSelection.height/sizey); + maxScale = self.maxScale = Min(self/*.scaledSelection*/.width/sizex, self/*.scaledSelection*/.height/sizey); self.scale = baseScale; self.min_neighbors = min_neighbors; self.scale_inc = scale_inc;