The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

faceboxlist.cc

Go to the documentation of this file.
00001 /* 
00002  *  faceboxlist.cc
00003  *
00004  *  Created by Ian Fasel on Feb 02, 2003.
00005  *  Fixes: 
00006  * 
00007  *  Copyright (c) 2003 Machine Perception Laboratory 
00008  *  University of California San Diego.
00009  * 
00010  * Please read the disclaimer and notes about redistribution 
00011  * at the end of this file.
00012  */
00013 
00014 #include "faceboxlist.h"
00015 #include <list>
00016 #include <math.h>
00017 #include <iostream>
00018 
00019 
00020 avg_object::avg_object():l(0),r(0),t(0),b(0),scale(0),
00021 nL(1),nR(1),nT(1),nB(1),nScale(1),normalized(false){}
00022 
00023 avg_object::avg_object(const avg_object &v):l(v.l),r(v.r),t(v.t),b(v.b),scale(v.scale),
00024 nL(v.nL),nR(v.nR),nT(v.nT),nB(v.nB),nScale(v.nScale),normalized(v.normalized){}
00025 
00026 avg_object::~avg_object(){}
00027 
00028 avg_object avg_object::operator+(const avg_object& v) const{
00029   avg_object tmp = *this;
00030   if(tmp.normalized) tmp.unnormalize();
00031   if(!v.normalized){
00032           if(tmp.l > 0){
00033                   tmp.l += v.l; tmp.nL += v.nL;}
00034           if(tmp.r > 0){
00035                   tmp.r += v.r; tmp.nR += v.nR;}
00036           if(tmp.t > 0){
00037                   tmp.t += v.t; tmp.nT += v.nT;}
00038           if(tmp.b > 0){
00039                   tmp.b += v.b; tmp.nB += v.nB;}
00040           if(tmp.scale > 0){
00041                   tmp.scale += v.scale; tmp.nScale += v.nScale;}
00042   }
00043   else{
00044           if(tmp.l > 0){
00045                   tmp.l += v.l*v.nL; tmp.nL += v.nL;}
00046           if(tmp.r > 0){
00047                   tmp.r += v.r*v.nR; tmp.nR += v.nR;}
00048           if(tmp.t > 0){
00049                   tmp.t += v.t*v.nT; tmp.nT += v.nT;}
00050           if(tmp.b > 0){
00051                   tmp.b += v.b*v.nB; tmp.nB += v.nB;}
00052           if(tmp.scale > 0){
00053                   tmp.scale += v.scale*v.nScale; tmp.nScale += v.nScale;}
00054   }
00055   return tmp;
00056 }
00057 
00058 avg_object & avg_object::operator+=(const avg_object &v){
00059   if(normalized) unnormalize();
00060   if(!v.normalized){
00061           if(l > 0){
00062                   l += v.l; nL += v.nL;}
00063           if(r > 0){
00064                   r += v.r; nR += v.nR;}
00065           if(t > 0){
00066                   t += v.t; nT += v.nT;}
00067           if(b > 0){
00068                   b += v.b; nB += v.nB;}
00069           if(scale > 0){
00070                   scale += v.scale; nScale += v.nScale;}
00071   }
00072   else{
00073           if(l > 0){
00074                   l += v.l*v.nL; nL += v.nL;}
00075           if(r > 0){
00076                   r += v.r*v.nR; nR += v.nR;}
00077           if(t > 0){
00078                   t += v.t*v.nT; nT += v.nT;}
00079           if(b > 0){
00080                   b += v.b*v.nB; nB += v.nB;}
00081           if(scale > 0){
00082                   scale += v.scale*v.nScale; nScale += v.nScale;}
00083   }
00084   return *this;
00085 }
00086 
00087 void avg_object::normalize(){
00088   t*=1.0f/nT; b*=1.0f/nB; l*=1.0f/nL; r*=1.0f/nR; scale*=1.0f/nScale;
00089   normalized = true;
00090 }
00091 
00092 void avg_object::unnormalize(){
00093   t*=nT; b*=nB; l*=nL; r*=nR; scale*=nScale;
00094   normalized = false;
00095 }
00096 
00097 
00098 /*avg_object::avg_object():l(0),r(0),t(0),b(0),n(1),scale(0),normalized(false){}
00099 
00100 avg_object::avg_object(const avg_object &v):l(v.l),r(v.r),t(v.t),b(v.b),n(v.n),scale(v.scale),normalized(v.normalized){}
00101 
00102 avg_object::~avg_object(){}
00103 
00104 avg_object avg_object::operator+(const avg_object& v) const{
00105   avg_object tmp = *this;
00106   if(tmp.normalized) tmp.unnormalize();
00107   if(!v.normalized){
00108     tmp.l+=v.l; tmp.r+=v.r; tmp.t+=v.t; tmp.b+=v.b; tmp.scale+=v.scale; tmp.n+=v.n;}
00109   else{
00110     tmp.l+=v.l*v.n; tmp.r+=v.r*v.n; tmp.t+=v.t*v.n; tmp.b+=v.b*v.n; tmp.scale+=v.scale*v.n; tmp.n+=v.n;
00111   }
00112   return tmp;
00113 }
00114 
00115 avg_object & avg_object::operator+=(const avg_object &v){
00116   if(normalized) unnormalize();
00117   if(!v.normalized){
00118     l += v.l; r += v.r; t += v.t; b += v.b; n += v.n; scale += v.scale;}
00119   else{
00120     l += v.l*v.n; r += v.r*v.n; t += v.t*v.n; b += v.b*v.n; n += v.n; scale += v.scale*v.n;
00121   }
00122   return *this;
00123 }
00124 
00125 void avg_object::normalize(){
00126   float v = 1.0f/n;
00127   t*=1.0f/n; b*=1.0f/n; l*=1.0f/n; r*=1.0f/n; scale*=1.0f/n;
00128   normalized = true;
00129 }
00130 
00131 void avg_object::unnormalize(){
00132   t*=n; b*=n; l*=n; r*=n; scale*=n;
00133   normalized = false;
00134 }
00135 
00136 
00137 */
00138 
00139 
00140 /*
00141  * 
00142  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00143  * 
00144  *    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00145  *    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
00146  *    3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
00147  * 
00148  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00149  * 
00150  */
00151 

Generated on Mon Nov 8 17:07:33 2004 for MPT by  doxygen 1.3.9.1