Changeset 17214 for lang/actionscript
- Timestamp:
- 08/07/08 22:28:42 (5 years ago)
- Location:
- lang/actionscript/ashaardetect/trunk/cv
- Files:
-
- 1 added
- 3 modified
-
HaarCascade.as (modified) (4 diffs)
-
HaarCascade.mas (modified) (4 diffs)
-
RectPool.as (added)
-
VideoDetector.as (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/ashaardetect/trunk/cv/HaarCascade.as
r17212 r17214 15 15 private var mSkipOverlap:Boolean = true; 16 16 private var mYieldContext:DetectContext = new DetectContext(); 17 private var mMaxWinWidth:uint = 1000000; 17 18 18 19 function HaarCascade() 19 20 { 20 21 22 } 23 24 public function set maxWinWidth(w:uint):void 25 { 26 mMaxWinWidth = w; 21 27 } 22 28 … … 90 96 var winHeight:uint; 91 97 var mask_index:uint = mYieldContext.mask_index; 98 var hueval:Number; 92 99 93 100 if (scale_factor == 0) … … 102 109 winWidth = factor * width + 0.5; 103 110 winHeight = factor * height + 0.5; 111 if (winWidth > mMaxWinWidth) 112 break; 104 113 105 114 if(winWidth < min_width || winHeight < min_height) … … 134 143 135 144 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; 137 150 continue; 151 } 138 152 } 139 153 -
lang/actionscript/ashaardetect/trunk/cv/HaarCascade.mas
r17212 r17214 17 17 private var mSkipOverlap:Boolean = true; 18 18 private var mYieldContext:DetectContext = new DetectContext(); 19 private var mMaxWinWidth:uint = 1000000; 19 20 20 21 function HaarCascade() 21 22 { 22 23 24 } 25 26 public function set maxWinWidth(w:uint):void 27 { 28 mMaxWinWidth = w; 23 29 } 24 30 … … 96 102 var winHeight:uint; 97 103 var mask_index:uint = mYieldContext.mask_index; 104 var hueval:Number; 98 105 99 106 if (scale_factor == 0) … … 108 115 winWidth = factor * width + 0.5; 109 116 winHeight = factor * height + 0.5; 117 if (winWidth > mMaxWinWidth) 118 break; 110 119 111 120 if(winWidth < min_width || winHeight < min_height) … … 140 149 141 150 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; 143 156 continue; 157 } 144 158 } 145 159 -
lang/actionscript/ashaardetect/trunk/cv/VideoDetector.as
r17212 r17214 22 22 private var mGenHue:Boolean; 23 23 24 private var mRectPool:RectPool = new RectPool(); 25 24 26 function VideoDetector(v:Video, dat:ByteArray) 25 27 { 26 28 mVideo = v; 27 29 mDetector = HaarCascade.fromBin(dat); 30 mDetector.maxWinWidth = 130; 28 31 } 29 32 … … 42 45 private function tick():void 43 46 { 47 var g:Graphics = graphics; 48 g.clear(); 44 49 if (!mOffscreen) { 45 50 mTmpData = new BitmapData(OFFSCR_WIDTH, OFFSCR_HEIGHT, false); … … 50 55 mCopyMat = new Matrix(); 51 56 mCopyMat.scale(mWRatio, mHRatio); 52 //var b:Bitmap = new Bitmap(mTmpData);53 //addChild(b);54 57 } 55 58 56 var detector_limit:uint = 400;59 var detector_limit:uint = 200; 57 60 if (mClearTmpBuf) 58 61 { … … 71 74 } 72 75 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); 74 77 var rc:Array; 75 78 if (res !== HaarCascade.YIELDED) … … 78 81 if (res) { 79 82 STDOUT.puts(res.length + " windows passed"); 80 81 var g:Graphics = graphics;82 g.clear();83 83 84 84 g.lineStyle(3, 0, 0.1); … … 90 90 g.drawRect(rc[0], rc[1], rc[2], rc[3]); 91 91 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 } 92 97 } 93 98 else { 99 mRectPool.update([]); 94 100 graphics.clear(); 95 101 STDOUT.puts("None"); … … 99 105 } 100 106 107 mRectPool.tick(); 108 mRectPool.draw(g, 0xff0044); 101 109 } 102 110 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)