From d2f36b53cd72dc6e2d627faeea21be01507b758a Mon Sep 17 00:00:00 2001 From: gaillaro Date: Sat, 9 Apr 2005 17:51:14 +0000 Subject: classe de détection d'orientation d'une masse de point --- 2005/i/robert/src/ovision/see/hotelling.cc | 64 +++++++++++++++++++++++++++++ 2005/i/robert/src/ovision/see/hotelling.hh | 65 ++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 2005/i/robert/src/ovision/see/hotelling.cc create mode 100644 2005/i/robert/src/ovision/see/hotelling.hh (limited to '2005/i') diff --git a/2005/i/robert/src/ovision/see/hotelling.cc b/2005/i/robert/src/ovision/see/hotelling.cc new file mode 100644 index 0000000..b492510 --- /dev/null +++ b/2005/i/robert/src/ovision/see/hotelling.cc @@ -0,0 +1,64 @@ +// hotelling.cc - Classe Hotelling +// robert - Programme du robot APBteam +// Copyright (C) 2005 Olivier Gaillard + +#include + +#include "hotelling.hh" + +/// Constructeur +Hotelling::Hotelling (const std::vector &dataList) +{ + e1_[0] = 0; e1_[1] = 0; e2_[0] = 0; e2_[1] = 0; + oconfig_ = OConfig::getInstance (); + + dataSize_ = dataList.size (); + if (dataSize_ == 0) + { + meanX_ = meanY_ = 0; + } + else + { + mean (dataList); + data_[0] = new uint8_t[dataSize_]; + data_[1] = new uint8_t[dataSize_]; + } + +} + +/// Destructeur +Hotelling::~Hotelling (void) +{ + delete [] covMatrix_; + delete [] data_; +} + +/// Calcul de la matrice de covariance +uint8_t* +Hotelling::cov () +{ + uint8_t *tab; + return tab; +} + +/// Calcul de la moyenne des deux composantes +void +Hotelling::mean (const std::vector &dataList) +{ + meanX_ = meanY_ = 0; + for (std::vector::const_iterator iter = dataList.begin (); + iter != dataList.end (); ++iter) + { + meanX_ += (*iter)[0]; + meanY_ += (*iter)[1]; + } + meanX_ /= dataSize_; + meanY_ /= dataSize_; +} + +/// Calcul des eigenvectors +void +Hotelling::eigenVectors () +{ +} + diff --git a/2005/i/robert/src/ovision/see/hotelling.hh b/2005/i/robert/src/ovision/see/hotelling.hh new file mode 100644 index 0000000..e3ac8bb --- /dev/null +++ b/2005/i/robert/src/ovision/see/hotelling.hh @@ -0,0 +1,65 @@ +// robert - programme du robot 2005 +// +// Copyright (C) 2005 Olivier Gaillard +// +// Robot APB Team/Efrei 2005. +// Web: http://assos.efrei.fr/robot/ +// Email: robot AT efrei DOT fr +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef hotelling_h +#define hotelling_h + +#include + +#include "oconfig.hh" + +/// Detecte l'orientation principale d'une masse de données +class Hotelling +{ + /// Classe oconfig + OConfig *oconfig_; + /// Matrice de covariance + uint8_t covMatrix_[2][2]; + /// Données à traitées ajustées + uint8_t *data_[2]; + /// Nombre d'échantillons de données + unsigned dataSize_; + /// Moyenne de la première et deuxième composante + int meanX_, meanY_; + /// EigenVectors + uint8_t e1_[2], e2_[2]; + + public: + /// Constructeur + Hotelling (const std::vector &dataList); + /// Destructeur + ~Hotelling (void); + /// Accessors + void getEigenVectors (uint8_t* &e1, uint8_t* &e2) + {e1 = e1_; e2 = e2_;} + void getPCA (uint8_t* &pca) {pca = e1_;} + + private: + /// Calcul de la matrice de covariance + uint8_t* cov (); + /// Calcul de la moyenne + void mean (const std::vector &dataList); + /// Calcul des eigenvectors + void eigenVectors (); +}; + +#endif // hotelling_h -- cgit v1.2.3