summaryrefslogtreecommitdiff
path: root/2005/i/robert/src
diff options
context:
space:
mode:
authorgaillaro2005-04-09 17:51:14 +0000
committergaillaro2005-04-09 17:51:14 +0000
commitd2f36b53cd72dc6e2d627faeea21be01507b758a (patch)
treefadcb0bdd8eca34c2e05e0b3b7e677879ef236ad /2005/i/robert/src
parent7cc8bf6a4cbd062f5d4f6e2b310cd603ab2c60e1 (diff)
classe de détection d'orientation d'une masse de point
Diffstat (limited to '2005/i/robert/src')
-rw-r--r--2005/i/robert/src/ovision/see/hotelling.cc64
-rw-r--r--2005/i/robert/src/ovision/see/hotelling.hh65
2 files changed, 129 insertions, 0 deletions
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 <iostream>
+
+#include "hotelling.hh"
+
+/// Constructeur
+Hotelling::Hotelling (const std::vector<uint8_t[2]> &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<uint8_t[2]> &dataList)
+{
+ meanX_ = meanY_ = 0;
+ for (std::vector<uint8_t[2]>::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 <vector>
+
+#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<uint8_t[2]> &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<uint8_t[2]> &dataList);
+ /// Calcul des eigenvectors
+ void eigenVectors ();
+};
+
+#endif // hotelling_h