Changeset 17167 for lang/actionscript
- Timestamp:
- 08/06/08 18:25:18 (4 months ago)
- Location:
- lang/actionscript/ashaardetect/trunk/cv
- Files:
-
- 2 added
- 2 modified
-
ClassifierTree.as (modified) (2 diffs)
-
HaarCascade.as (modified) (6 diffs)
-
HaarCascade.mas (added)
-
preprocess.rb (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/ashaardetect/trunk/cv/ClassifierTree.as
r17159 r17167 9 9 public var rects:Array = []; 10 10 public var scaled_rects:Array = []; 11 12 public var sr0:SRect = null; 13 public var sr1:SRect = null; 14 public var sr2:SRect = null; 11 15 12 16 public function readRectsFromBin(d:ByteArray):Boolean … … 51 55 sum0 += sr.weight * sr.w * th; 52 56 } 57 58 sr0 = scaled_rects[0]; 59 sr1 = scaled_rects[1]; 60 61 if (len > 2) 62 sr2 = scaled_rects[2]; 53 63 54 64 scaled_rects[0].weight = -sum0 / area0; -
lang/actionscript/ashaardetect/trunk/cv/HaarCascade.as
r17159 r17167 155 155 } 156 156 157 public static function cvRound(v:Number):int 158 { 159 return v+0.5; 160 } 161 162 private function initCascade(scale:Number, sums:SumImage):void 163 { 164 var equ_rect_width:int = cvRound((width-2)*scale); 165 var equ_rect_height:int = cvRound((height-2)*scale); 157 private function initCascade(scale:Number, sums:SumImage):void 158 { 159 var equ_rect_width:int = int(((width-2)*scale) + 0.5); 160 var equ_rect_height:int = int(((height-2)*scale) + 0.5); 166 161 mWeightScale = 1.0/Number(equ_rect_width*equ_rect_height); // cascade->inv_window_area 167 sums.setEqWindowRect( cvRound(scale), cvRound(scale), equ_rect_width, equ_rect_height);162 sums.setEqWindowRect(int((scale) + 0.5), int((scale) + 0.5), equ_rect_width, equ_rect_height); 168 163 // correction_ratio = mWeightScale; 169 164 for each(var stg:ClassifierStage in mStages) 170 165 stg.calcScale(scale, mWeightScale, sums); 171 166 } 172 //public static var dcount:int = 0; 173 private function cvRunHaarClassifierCascade(ix:int, iyp:int, start_stage:int, sums:SumImage, limit:int = 99):int174 { 175 /*167 168 private function cvRunHaarClassifierCascade(ix:int, iyp:int, start_stage:int, sums:SumImage, limit:int = 99):int 169 { 170 /* 176 171 if( ix < 0 || iy < 0 || 177 172 (ix + width) >= (sums.width-2 ) || … … 192 187 var cascade_count:int = mStages.length; 193 188 var sum:Number; 194 var rects:Array; 189 195 190 if (cascade_count > limit) 196 191 cascade_count = limit; … … 214 209 { 215 210 node = stage.nodes[j]; 216 t = node.threshold*variance_norm_factor; 217 rects = node.scaled_rects; 218 r0 = rects[0]; 219 r1 = rects[1]; 211 r0 = node.sr0; 212 r1 = node.sr1; 220 213 w0 = r0.weight; 221 214 222 base = r0.base + ixyp; 223 base_w = base + r0.w; 215 base = r0.base + ixyp; 216 base_w = base + r0.w; 224 217 hh = r0.hh; 225 218 sum = (raw_sum[base] - raw_sum[base_w] - raw_sum[base + hh] + raw_sum[base_w + hh]) * w0; 226 219 227 base = r1.base + ixyp; 228 base_w = base + r1.w; 220 base = r1.base + ixyp; 221 base_w = base + r1.w; 229 222 hh = r1.hh; 230 223 sum += (raw_sum[base] - raw_sum[base_w] - raw_sum[base + hh] + raw_sum[base_w + hh]) * r1.weight; … … 233 226 b = node.right; 234 227 235 if (sum < t) stage_sum += a;228 if (sum < (node.threshold*variance_norm_factor)) stage_sum += a; 236 229 else stage_sum += b; 237 230 … … 243 236 { 244 237 node = stage.nodes[j]; 245 t = node.threshold*variance_norm_factor 246 rects = node.scaled_rects; 247 r0 = rects[0]; 248 r1 = rects[1]; 249 250 base = r0.base + ixyp; 251 base_w = base + r0.w; 238 r0 = node.sr0; 239 r1 = node.sr1; 240 241 base = r0.base + ixyp; 242 base_w = base + r0.w; 252 243 hh = r0.hh; 253 244 sum = (raw_sum[base] - raw_sum[base_w] - raw_sum[base + hh] + raw_sum[base_w + hh]) * r0.weight; 254 245 255 base = r1.base + ixyp; 256 base_w = base + r1.w; 246 base = r1.base + ixyp; 247 base_w = base + r1.w; 257 248 hh = r1.hh; 258 249 sum += (raw_sum[base] - raw_sum[base_w] - raw_sum[base + hh] + raw_sum[base_w + hh]) * r1.weight; 259 250 260 if ( rects[2])251 if (node.sr2) 261 252 { 262 r2 = rects[2];263 base = r2.base + ixyp; 264 base_w = base + r2.w;265 hh = r2.hh;253 r2 = node.sr2; 254 base = r2.base + ixyp; 255 base_w = base + r2.w; 256 hh = r2.hh; 266 257 sum += (raw_sum[base] - raw_sum[base_w] - raw_sum[base + hh] + raw_sum[base_w + hh]) * r2.weight; 267 258 } … … 269 260 a = node.left; 270 261 b = node.right; 271 if (sum < t) stage_sum += a;262 if (sum < (node.threshold*variance_norm_factor)) stage_sum += a; 272 263 else stage_sum += b; 273 264 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)