Changeset 17214 for lang/actionscript

Show
Ignore:
Timestamp:
08/07/08 22:28:42 (5 years ago)
Author:
gyuque
Message:

added RectPool?

Location:
lang/actionscript/ashaardetect/trunk/cv
Files:
1 added
3 modified

Legend:

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

    r17212 r17214  
    1515                private var mSkipOverlap:Boolean = true; 
    1616                private var mYieldContext:DetectContext = new DetectContext(); 
     17                private var mMaxWinWidth:uint = 1000000; 
    1718 
    1819                function HaarCascade() 
    1920                { 
    2021 
     22                } 
     23 
     24                public function set maxWinWidth(w:uint):void 
     25                { 
     26                        mMaxWinWidth = w; 
    2127                } 
    2228 
     
    9096                        var winHeight:uint; 
    9197                        var mask_index:uint = mYieldContext.mask_index; 
     98                        var hueval:Number; 
    9299 
    93100                        if (scale_factor == 0) 
     
    102109                                winWidth  = factor * width  + 0.5; 
    103110                                winHeight = factor * height + 0.5; 
     111                                if (winWidth > mMaxWinWidth) 
     112                                        break; 
    104113 
    105114                                if(winWidth < min_width || winHeight < min_height) 
     
    134143 
    135144                                                                if (Hsum) { 
    136                                                                         if ((Hsum.calc_esum(ix, iyp) / Number(Hsum.eqArea)) < 0.4) 
     145                                                                        hueval = (Hsum.calc_esum(ix, iyp) / Number(Hsum.eqArea)); 
     146                                                                        if (hueval < 0.4) 
     147                                                                        { 
     148                                                                                if (hueval < 0.2) 
     149                                                                                        _xstep = 4; 
    137150                                                                                continue; 
     151                                                                        } 
    138152                                                                } 
    139153 
  • lang/actionscript/ashaardetect/trunk/cv/HaarCascade.mas

    r17212 r17214  
    1717                private var mSkipOverlap:Boolean = true; 
    1818                private var mYieldContext:DetectContext = new DetectContext(); 
     19                private var mMaxWinWidth:uint = 1000000; 
    1920 
    2021                function HaarCascade() 
    2122                { 
    2223 
     24                } 
     25 
     26                public function set maxWinWidth(w:uint):void 
     27                { 
     28                        mMaxWinWidth = w; 
    2329                } 
    2430 
     
    96102                        var winHeight:uint; 
    97103                        var mask_index:uint = mYieldContext.mask_index; 
     104                        var hueval:Number; 
    98105 
    99106                        if (scale_factor == 0) 
     
    108115                                winWidth  = factor * width  + 0.5; 
    109116                                winHeight = factor * height + 0.5; 
     117                                if (winWidth > mMaxWinWidth) 
     118                                        break; 
    110119 
    111120                                if(winWidth < min_width || winHeight < min_height) 
     
    140149 
    141150                                                                if (Hsum) { 
    142                                                                         if ((Hsum.calc_esum(ix, iyp) / Number(Hsum.eqArea)) < 0.4) 
     151                                                                        hueval = (Hsum.calc_esum(ix, iyp) / Number(Hsum.eqArea)); 
     152                                                                        if (hueval < 0.4) 
     153                                                                        { 
     154                                                                                if (hueval < 0.2) 
     155                                                                                        _xstep = 4; 
    143156                                                                                continue; 
     157                                                                        } 
    144158                                                                } 
    145159 
  • lang/actionscript/ashaardetect/trunk/cv/VideoDetector.as

    r17212 r17214  
    2222                private var mGenHue:Boolean; 
    2323 
     24                private var mRectPool:RectPool = new RectPool(); 
     25 
    2426                function VideoDetector(v:Video, dat:ByteArray) 
    2527                { 
    2628                        mVideo = v; 
    2729                        mDetector = HaarCascade.fromBin(dat); 
     30                        mDetector.maxWinWidth = 130; 
    2831                } 
    2932 
     
    4245                private function tick():void 
    4346                { 
     47                        var g:Graphics = graphics; 
     48                        g.clear(); 
    4449                        if (!mOffscreen) { 
    4550                                mTmpData   = new BitmapData(OFFSCR_WIDTH, OFFSCR_HEIGHT, false); 
     
    5055                                mCopyMat = new Matrix(); 
    5156                                mCopyMat.scale(mWRatio, mHRatio); 
    52 //var b:Bitmap = new Bitmap(mTmpData); 
    53 //addChild(b); 
    5457                        } 
    5558 
    56                         var detector_limit:uint = 400; 
     59                        var detector_limit:uint = 200; 
    5760                        if (mClearTmpBuf) 
    5861                        { 
     
    7174                        } 
    7275 
    73                         var res:Object = mDetector.detect(mTmpData, 1.2, 54, 54, detector_limit); 
     76                        var res:Object = mDetector.detect(mTmpData, 1.2, 44, 44, detector_limit); 
    7477                        var rc:Array; 
    7578                        if (res !== HaarCascade.YIELDED) 
     
    7881                                if (res) { 
    7982                                        STDOUT.puts(res.length + " windows passed"); 
    80          
    81                                         var g:Graphics = graphics; 
    82                                         g.clear(); 
    8383 
    8484                                        g.lineStyle(3, 0, 0.1); 
     
    9090                                                g.drawRect(rc[0], rc[1], rc[2], rc[3]); 
    9191 
     92                                        var clss:Array = U.bindNeighborRects(res as Array); 
     93                                        if (clss) { 
     94                                                res = U.uniteRects(res as Array, clss, 2); 
     95                                                mRectPool.update(res as Array); 
     96                                        } 
    9297                                } 
    9398                                else { 
     99                                        mRectPool.update([]); 
    94100                                        graphics.clear(); 
    95101                                        STDOUT.puts("None"); 
     
    99105                        } 
    100106 
     107                        mRectPool.tick(); 
     108                        mRectPool.draw(g, 0xff0044); 
    101109                } 
    102110        }