private void createCascadeRegion ( int imageWidth , int imageHeight ) { cascadeRegions . reset ( ) ; int rectWidth = ( int ) ( targetRegion . getWidth ( ) + 0.5 ) ; int rectHeight = ( int ) ( targetRegion . getHeight ( ) + 0.5 ) ; for ( int scaleInt = - config . scaleSpread ; scaleInt <= config . scaleSpread ; scaleInt ++ ) { // try several scales as specified in the paper double scale = Math . pow ( 1.2 , scaleInt ) ; // the actual rectangular region being tested at this scale int actualWidth = ( int ) ( rectWidth * scale ) ; int actualHeight = ( int ) ( rectHeight * scale ) ; // see if the region is too small or too large if ( actualWidth < config . detectMinimumSide || actualHeight < config . detectMinimumSide ) continue ; if ( actualWidth >= imageWidth || actualHeight >= imageHeight ) continue ; // step size at this scale int stepWidth = ( int ) ( rectWidth * scale * 0.1 ) ; int stepHeight = ( int ) ( rectHeight * scale * 0.1 ) ; if ( stepWidth < 1 ) stepWidth = 1 ; if ( stepHeight < 1 ) stepHeight = 1 ; // maximum allowed values int maxX = imageWidth - actualWidth ; int maxY = imageHeight - actualHeight ; // start at (1,1). Otherwise a more complex algorithm needs to be used for integral images for ( int y0 = 1 ; y0 < maxY ; y0 += stepHeight ) { for ( int x0 = 1 ; x0 < maxX ; x0 += stepWidth ) { ImageRectangle r = cascadeRegions . grow ( ) ; r . x0 = x0 ; r . y0 = y0 ; r . x1 = x0 + actualWidth ; r . y1 = y0 + actualHeight ; } } } }
Creates a list containing all the regions which need to be tested