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

beyesobject.cpp

Go to the documentation of this file.
00001 /* 
00002  *  BEYESOBJECT.cpp
00003  *
00004  *  Created by Bret Fortenberry on Aug 27, 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 
00015 #include "beyesobject.h"
00016 #include <cmath>
00017 #include <math.h>
00018 
00019 
00020 #define xfactor 1.56f//1.56
00021 #define yfactor 0.78f
00022 
00023 bEyesObject::bEyesObject() : xLeft(0), yLeft(0), xRight(0), yRight(0), 
00024                    leftScale(0), rightScale(0), leftEye(false), rightEye(false){}
00025                  
00026 bEyesObject::bEyesObject(float xLeft_in, float yLeft_in, float xRight_in, float yRight_in){
00027         xLeft = xLeft_in;
00028         yLeft = yLeft_in;
00029         xRight = xRight_in; 
00030         yRight = yRight_in;
00031 }
00032 
00033 bEyesObject::bEyesObject(bEyesObject &thelist)
00034 {
00035         x = thelist.x;
00036         y = thelist.y;
00037         xSize = thelist.xSize;
00038         ySize = thelist.ySize;
00039         xLeft = thelist.xLeft;
00040         yLeft = thelist.yLeft;
00041         xRight = thelist.xRight;
00042         yRight = thelist.yRight;
00043         degrees = thelist.degrees;
00044         leftEye = thelist.leftEye;
00045         rightEye = thelist.rightEye;
00046         scale = thelist.scale;
00047 }
00048 
00049 
00050 bEyesObject::~bEyesObject() {}
00051 
00052 int bEyesObject::findBox()
00053 {
00054         if(!leftEye || !rightEye)
00055                 return 0;
00056         xSize = static_cast<float>(floor(findEucDis()*xfactor));
00057         ySize = static_cast<float>(floor(xSize/2));
00058         degrees = atan2((yRight-yLeft),(xLeft-xRight));
00059     float width = xLeft-xRight;
00060         float midpointx = xRight + static_cast<float>(floor(width/2));
00061         float midpointy = yRight + static_cast<float>(floor((yLeft-yRight)/2)); 
00062         x = midpointx - static_cast<float>(floor(cos(degrees)*(xSize*.5) + sin(degrees)*(ySize*.5)));
00063         y = midpointy + static_cast<float>(floor(sin(degrees)*(xSize*.5) - cos(degrees)*(ySize*.5)));
00064         return 1;
00065 }
00066 
00067 float bEyesObject::getAbs(float x){
00068         float rtn = x;
00069         if(x < 0){
00070                 float temp = x * 2;
00071                 rtn = x - temp;
00072         }
00073         return rtn;
00074 }               
00075 
00076 double bEyesObject::findEucDis()
00077 {
00078         double xSquare = getAbs(xLeft-xRight) * getAbs(xLeft-xRight);
00079         double ySquare = getAbs(yLeft-yRight) * getAbs(yLeft-yRight);
00080         double EucDis = sqrt(xSquare + ySquare);
00081         return EucDis;
00082 }
00083 
00084 
00085 
00086 /*
00087  * 
00088  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00089  * 
00090  *    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00091  *    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.
00092  *    3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
00093  * 
00094  * 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.
00095  * 
00096  */

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