From 2cccac9a44079ad6d7d474ac39e40b8e2270ead7 Mon Sep 17 00:00:00 2001 From: gaillaro Date: Sun, 1 May 2005 16:51:56 +0000 Subject: ajout des classes eraser pour tester la taille des quilles trouvées --- 2005/i/robert/src/ovision/see/eraser.cc | 52 ++++++++++++++++++++++++ 2005/i/robert/src/ovision/see/eraser.hh | 51 +++++++++++++++++++++++ 2005/i/robert/src/ovision/see/imgInterface.cc | 17 +++++--- 2005/i/robert/src/ovision/see/imgInterface.hh | 2 +- 2005/i/robert/src/ovision/see/oconfig.cc | 4 ++ 2005/i/robert/src/ovision/see/ovision.cc | 2 + 2005/i/robert/src/ovision/see/segm.cc | 4 +- 2005/i/robert/src/ovision/see/test_colortable.cc | 2 + 2005/i/robert/src/ovision/see/test_group.cc | 2 + 2005/i/robert/src/ovision/see/test_hotelling.cc | 2 + 2005/i/robert/src/ovision/see/test_magnifier.cc | 1 + 2005/i/robert/src/ovision/see/test_ovision.cc | 5 ++- 12 files changed, 133 insertions(+), 11 deletions(-) create mode 100644 2005/i/robert/src/ovision/see/eraser.cc create mode 100644 2005/i/robert/src/ovision/see/eraser.hh (limited to '2005/i/robert') diff --git a/2005/i/robert/src/ovision/see/eraser.cc b/2005/i/robert/src/ovision/see/eraser.cc new file mode 100644 index 0000000..a2393ed --- /dev/null +++ b/2005/i/robert/src/ovision/see/eraser.cc @@ -0,0 +1,52 @@ +// eraser.cc - Classe Eraser +// robert - Programme du robot APBteam +// Copyright (C) 2005 Olivier Gaillard + +/// @file eraser.cc Filtre les objets par leurs tailles + +#include + +#include "eraser.hh" + +/// Constructeur +Eraser::Eraser (const std::string &filename, const int resolution) + : res_ (resolution) +{ + oconfig_ = OConfig::getInstance (); + init (); +} + +/// Destructeur +Eraser::~Eraser (void) +{ +} + +/// Ouvre le fichier de données +Eraser::init (std::string &filename) +{ + // Ouverture du fichier de distance + std::ifstream file (filename); + if (!file) { + throw " Error during file opening"; + return; + } + // Parcours des lignes et analyse +} + +/// Objet à la bonne taille ? +bool +Eraser::killOrNot (const Zone &zone) +{ + int y = zone.ymax % res_; + if (zone.vertical) + { + if ((zone.area > tabVMin[y]) || (zone.area < tabVMax[y])) + return true; + } + else + { + if ((zone.area > tabOMin[y]) || (zone.area < tabOMax[y])) + return true; + } + return false; +} diff --git a/2005/i/robert/src/ovision/see/eraser.hh b/2005/i/robert/src/ovision/see/eraser.hh new file mode 100644 index 0000000..7a98626 --- /dev/null +++ b/2005/i/robert/src/ovision/see/eraser.hh @@ -0,0 +1,51 @@ +// 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 eraser_h +#define eraser_h + +#include + +#include "oconfig.hh" + +/// Filtre les objets par taille +class Eraser +{ + /// Classe oconfig + OConfig *oconfig_; + /// Tableau des tailles pour une quille verticale + std::vector tabVMin; + std::vector tabVMax; + /// Tableau des tailles pour une quille oblique + std::vector tabOMin; + std::vector tabOMax; + + public: + /// Constructeur + Eraser (const std::string &filename, const int resolution); + /// Destructeur + ~Eraser (void); + + private: +}; + +#endif // eraser_h diff --git a/2005/i/robert/src/ovision/see/imgInterface.cc b/2005/i/robert/src/ovision/see/imgInterface.cc index bafe0b3..d41000d 100644 --- a/2005/i/robert/src/ovision/see/imgInterface.cc +++ b/2005/i/robert/src/ovision/see/imgInterface.cc @@ -15,6 +15,12 @@ ImgInterface::ImgInterface () : tabOut_ (0) {} +/// Destructeur +ImgInterface::~ImgInterface () +{ + delete [] tabOut_; +} + /// Cree un tableau en RGB pour l'affichage a partir d'une image segmentee /// @param *tabIn pointeur vers un tableau de donnees segmentees /// @param *tabOut_ pointeur vers un tableau de donnees RGB @@ -23,8 +29,8 @@ ImgInterface::doImg (const unsigned char *tabIn) { /// Initialise les données if (!tabIn) tabIn = tabSegm_; - delete [] tabOut_; - tabOut_ = new unsigned char [nbPixels_ * 3]; + if (!tabOut_) + tabOut_ = new unsigned char [nbPixels_ * 3]; /// Remplissage de tabOut if (tabIn) { @@ -130,15 +136,14 @@ ImgInterface::doGroupImg (const std::vector &zoneList, bool init) // On verifie que des groupes ont ete trouve if (zoneList.empty ()) { std::cerr << "ImgInterface::doGroupImg: No group defined" << std::endl; - delete [] tabSegm_; - tabSegm_ = 0; + init = 1; return; } if (init) { // Allocation de la memoire - delete [] tabSegm_; - tabSegm_ = new unsigned char[nbPixels_]; + if (!tabSegm_) + tabSegm_ = new unsigned char[nbPixels_]; // On initialise le tableau pour une image noire for (unsigned int i=0; itabData_; - delete [] img->tabSegm_; - img->tabSegm_= new unsigned char[img->nbPixels_]; + if (!img->tabSegm_) + img->tabSegm_= new unsigned char[img->nbPixels_]; unsigned char *s = img->tabSegm_; // Parcours de l'image pour la segmentation // On recupere l'indextabSegm_et non le numero de sortie du NN diff --git a/2005/i/robert/src/ovision/see/test_colortable.cc b/2005/i/robert/src/ovision/see/test_colortable.cc index 5a0be81..7f76fbb 100644 --- a/2005/i/robert/src/ovision/see/test_colortable.cc +++ b/2005/i/robert/src/ovision/see/test_colortable.cc @@ -43,6 +43,8 @@ main(int argc, char **argv) segm.segmImg (&img); img.doImg (); img.writeRaw ("../runtime/shots/segm.rgb", img.getTabOut ()); + + delete oconfig_; return 0; } diff --git a/2005/i/robert/src/ovision/see/test_group.cc b/2005/i/robert/src/ovision/see/test_group.cc index b5f261f..e3f0b3a 100644 --- a/2005/i/robert/src/ovision/see/test_group.cc +++ b/2005/i/robert/src/ovision/see/test_group.cc @@ -51,5 +51,7 @@ main(int argc, char **argv) img.doGroupImg (test); img.doImg (img.getTabSegm ()); img.writeRaw ("../runtime/shots/group.rgb", img.getTabOut ()); + + delete oconfig_; } diff --git a/2005/i/robert/src/ovision/see/test_hotelling.cc b/2005/i/robert/src/ovision/see/test_hotelling.cc index 3f2bfbc..4edacb3 100644 --- a/2005/i/robert/src/ovision/see/test_hotelling.cc +++ b/2005/i/robert/src/ovision/see/test_hotelling.cc @@ -42,5 +42,7 @@ main(int argc, char **argv) hote.eigenVectors (); hote.showCovMatrix (); hote.showEigenVectors (); + + delete oconfig_; } diff --git a/2005/i/robert/src/ovision/see/test_magnifier.cc b/2005/i/robert/src/ovision/see/test_magnifier.cc index f57bb89..df1f4f3 100644 --- a/2005/i/robert/src/ovision/see/test_magnifier.cc +++ b/2005/i/robert/src/ovision/see/test_magnifier.cc @@ -52,6 +52,7 @@ main(int argc, char **argv) /// Analyse et tri la liste de zones trouvées mag.analyse (group.getZoneList ()); mag.showItems (Group::redSkittle); + delete oconfig_; } diff --git a/2005/i/robert/src/ovision/see/test_ovision.cc b/2005/i/robert/src/ovision/see/test_ovision.cc index 88cb6fe..3d00350 100644 --- a/2005/i/robert/src/ovision/see/test_ovision.cc +++ b/2005/i/robert/src/ovision/see/test_ovision.cc @@ -25,7 +25,8 @@ main(int argv, char **argc) } OVision ovision; ovision.init (aim); - while (1) + int t = 50; + while (t--) { // Prends une image ovision.takeShoot (); @@ -37,7 +38,7 @@ main(int argv, char **argc) double x, y; // if (ovision.getBall (x, y)) // std::cout << x <<"----" << y << std::endl; - sleep (5); + usleep (500000); } return 0; } -- cgit v1.2.3