Show
Ignore:
Timestamp:
08/13/08 00:51:51 (5 months ago)
Author:
gyuque
Message:

updated and added sample

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/ashaardetect/trunk/cv/HaarCascade.mas

    r17274 r17558  
    2121                private var mSpecificityList:Array; 
    2222 
     23                private var mSourceWindow:IntRect = null; 
     24 
    2325                #define SPL_STEP 10 
    2426 
     
    3638                { 
    3739                        return mSpecificityList; 
     40                } 
     41 
     42                public function setSourceWindow(x:int, y:int, w:int, h:int):void 
     43                { 
     44                        if (!mSourceWindow) 
     45                                mSourceWindow = new IntRect(); 
     46 
     47                        mSourceWindow.x = x; 
     48                        mSourceWindow.y = y; 
     49                        mSourceWindow.w = w; 
     50                        mSourceWindow.h = h; 
    3851                } 
    3952 
     
    101114                                mYieldContext.res  = null; 
    102115                                mYieldContext.factor = 1; 
    103                                 mYieldContext.sumimage = new SumImage(bmp); 
     116                                if (mSourceWindow) 
     117                                        mYieldContext.sumimage = new SumImage(bmp, true, mSourceWindow.y, mSourceWindow.h); 
     118                                else 
     119                                        mYieldContext.sumimage = new SumImage(bmp, true); 
     120 
    104121                                mYieldContext.Hsumimage = null; 
    105122                                mYieldContext.mask_index = 1; 
     
    115132                        var pass:uint = 0; 
    116133 
     134                        var ox:int = 0; 
     135                        var oy:int = 0; 
     136 
    117137                        mSumRaw = sums.raw; 
    118138                        mSumW = sums.width; 
     
    120140                        var srcWidth:uint = bmp.width; 
    121141                        var srcHeight:uint = bmp.height; 
     142 
     143                        if (mSourceWindow) { 
     144                                srcWidth  = mSourceWindow.w; 
     145                                srcHeight = mSourceWindow.h; 
     146                                ox = mSourceWindow.x; 
     147                                oy = mSourceWindow.y; 
     148                        } 
     149 
    122150                        var winWidth:uint; 
    123151                        var winHeight:uint; 
     
    131159 
    132160                        for( ; factor*Number(width)  < (srcWidth  - 10) && 
    133                                  factor*Number(height) < (srcHeight - 10); 
     161                                 factor*Number(height) < (srcHeight - 20); 
    134162                                factor *= scale_factor, ++mask_index ) 
    135163                        { 
     
    177205 
    178206                                                var _ix:uint, _xstep:uint = 1; 
    179                                                 iy = cvRound(_iy*ystep); 
     207                                                iy = cvRound(_iy*ystep) + oy; 
    180208                                                iyp = iy * mSumW; 
    181209 
     
    183211                                                for( _ix = 0; _ix < stop_width; _ix += _xstep ) 
    184212                                                { 
    185                                                         var ix:int = _ix*ystep; // it really should be ystep 
     213                                                        var ix:int = _ix*ystep + ox; // it really should be ystep 
    186214 
    187215                                                        if(pass == 0) 
     
    389417        public var Hsumimage:SumImage; 
    390418} 
     419 
     420class IntRect 
     421{ 
     422        public var x:int, y:int, w:int, h:int; 
     423}