| 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 Feature3Rects extends FeatureBase { |
|---|
| 33 |
public var r1 :HaarRect; |
|---|
| 34 |
public var r2 :HaarRect; |
|---|
| 35 |
public var r3 :HaarRect; |
|---|
| 36 |
|
|---|
| 37 |
public function Feature3Rects(_t:int, _th:Number, _lv:Number, _rv:Number){ |
|---|
| 38 |
super(_t,_th,_lv,_rv); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
public override function getSum( t:TargetImage, offsetx:int, offsety:int ):Number{ |
|---|
| 42 |
var sum:Number = 0; |
|---|
| 43 |
sum += t.getSum( offsetx + r1.sx, offsety + r1.sy, r1.sw, r1.sh ) * r1.sweight; |
|---|
| 44 |
sum += t.getSum( offsetx + r2.sx, offsety + r2.sy, r2.sw, r2.sh ) * r2.sweight; |
|---|
| 45 |
sum += t.getSum( offsetx + r3.sx, offsety + r3.sy, r3.sw, r3.sh ) * r3.sweight; |
|---|
| 46 |
return sum; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
public override function setScaleAndWeight(s:Number,w:Number):void{ |
|---|
| 50 |
r2.scale = s; |
|---|
| 51 |
r2.scale_weight = w; |
|---|
| 52 |
r3.scale = s; |
|---|
| 53 |
r3.scale_weight = w; |
|---|
| 54 |
r1.scale = s; |
|---|
| 55 |
r1.sweight = - ( r2.area * r2.sweight + r3.area * r3.sweight ) / r1.area; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
public override function setRect(r:HaarRect,i:int):void{ |
|---|
| 59 |
switch(i){ |
|---|
| 60 |
case 0: |
|---|
| 61 |
r1 = r; |
|---|
| 62 |
break; |
|---|
| 63 |
case 1: |
|---|
| 64 |
r2 = r; |
|---|
| 65 |
break; |
|---|
| 66 |
case 2: |
|---|
| 67 |
r3 = r; |
|---|
| 68 |
break; |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|