| 1 |
// |
|---|
| 2 |
// Project Marilena |
|---|
| 3 |
// Object Detection in Actionscript3 |
|---|
| 4 |
// based on OpenCV (Open Computer Vision Library) Object Detection |
|---|
| 5 |
// |
|---|
| 6 |
// Copyright (C) 2008, Masakazu OHTSUKA (mash), all rights reserved. |
|---|
| 7 |
// contact o.masakazu(at)gmail.com |
|---|
| 8 |
// |
|---|
| 9 |
// Redistribution and use in source and binary forms, with or without modification, |
|---|
| 10 |
// are permitted provided that the following conditions are met: |
|---|
| 11 |
// |
|---|
| 12 |
// * Redistribution's of source code must retain the above copyright notice, |
|---|
| 13 |
// this list of conditions and the following disclaimer. |
|---|
| 14 |
// |
|---|
| 15 |
// * Redistribution's in binary form must reproduce the above copyright notice, |
|---|
| 16 |
// this list of conditions and the following disclaimer in the documentation |
|---|
| 17 |
// and/or other materials provided with the distribution. |
|---|
| 18 |
// |
|---|
| 19 |
// This software is provided by the copyright holders and contributors "as is" and |
|---|
| 20 |
// any express or implied warranties, including, but not limited to, the implied |
|---|
| 21 |
// warranties of merchantability and fitness for a particular purpose are disclaimed. |
|---|
| 22 |
// In no event shall the Intel Corporation or contributors be liable for any direct, |
|---|
| 23 |
// indirect, incidental, special, exemplary, or consequential damages |
|---|
| 24 |
// (including, but not limited to, procurement of substitute goods or services; |
|---|
| 25 |
// loss of use, data, or profits; or business interruption) however caused |
|---|
| 26 |
// and on any theory of liability, whether in contract, strict liability, |
|---|
| 27 |
// or tort (including negligence or otherwise) arising in any way out of |
|---|
| 28 |
// the use of this software, even if advised of the possibility of such damage. |
|---|
| 29 |
// |
|---|
| 30 |
package jp.maaash.ObjectDetection |
|---|
| 31 |
{ |
|---|
| 32 |
public class HaarCascade{ |
|---|
| 33 |
public var base_window_w :int; |
|---|
| 34 |
public var base_window_h :int; |
|---|
| 35 |
public var inv_window_area :Number; |
|---|
| 36 |
public var trees :Array = new Array; |
|---|
| 37 |
private var _scale :Number = 0; |
|---|
| 38 |
|
|---|
| 39 |
public function HaarCascade() { |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
public function set scale(s:Number):void{ |
|---|
| 43 |
if( s==_scale ){ return; } |
|---|
| 44 |
_scale = s; |
|---|
| 45 |
// update rect's width, height, weight |
|---|
| 46 |
var treenums :int = trees.length, tree :FeatureTree, featurenums :int, i:int=0, j:int=0; |
|---|
| 47 |
inv_window_area = 1/(base_window_w*base_window_h*s*s); |
|---|
| 48 |
for( i=0; i<treenums; i++ ){ |
|---|
| 49 |
tree = trees[i]; |
|---|
| 50 |
featurenums = tree.features.length; |
|---|
| 51 |
for( j=0; j<featurenums; j++ ){ |
|---|
| 52 |
tree.features[j].setScaleAndWeight( s, inv_window_area ); |
|---|
| 53 |
} |
|---|
| 54 |
} |
|---|
| 55 |
} |
|---|
| 56 |
} |
|---|
| 57 |
} |
|---|