summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgaillaro2005-05-01 16:51:56 +0000
committergaillaro2005-05-01 16:51:56 +0000
commit2cccac9a44079ad6d7d474ac39e40b8e2270ead7 (patch)
treedbc82e2031075bc136009477ce65ba4b9682aff1
parent45833f980001efc4ee7468187a4a37042776e12e (diff)
ajout des classes eraser pour tester la taille des quilles trouvées
-rw-r--r--2005/i/robert/src/ovision/see/eraser.cc52
-rw-r--r--2005/i/robert/src/ovision/see/eraser.hh51
-rw-r--r--2005/i/robert/src/ovision/see/imgInterface.cc17
-rw-r--r--2005/i/robert/src/ovision/see/imgInterface.hh2
-rw-r--r--2005/i/robert/src/ovision/see/oconfig.cc4
-rw-r--r--2005/i/robert/src/ovision/see/ovision.cc2
-rw-r--r--2005/i/robert/src/ovision/see/segm.cc4
-rw-r--r--2005/i/robert/src/ovision/see/test_colortable.cc2
-rw-r--r--2005/i/robert/src/ovision/see/test_group.cc2
-rw-r--r--2005/i/robert/src/ovision/see/test_hotelling.cc2
-rw-r--r--2005/i/robert/src/ovision/see/test_magnifier.cc1
-rw-r--r--2005/i/robert/src/ovision/see/test_ovision.cc5
12 files changed, 133 insertions, 11 deletions
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 <iostream>
+
+#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 "<Eraser::init> 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 <vector>
+
+#include "oconfig.hh"
+
+/// Filtre les objets par taille
+class Eraser
+{
+ /// Classe oconfig
+ OConfig *oconfig_;
+ /// Tableau des tailles pour une quille verticale
+ std::vector<unsigned> tabVMin;
+ std::vector<unsigned> tabVMax;
+ /// Tableau des tailles pour une quille oblique
+ std::vector<unsigned> tabOMin;
+ std::vector<unsigned> 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<Zone> &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; i<nbPixels_; i++)
tabSegm_[i] = 0;
diff --git a/2005/i/robert/src/ovision/see/imgInterface.hh b/2005/i/robert/src/ovision/see/imgInterface.hh
index 0117eef..4b76cdc 100644
--- a/2005/i/robert/src/ovision/see/imgInterface.hh
+++ b/2005/i/robert/src/ovision/see/imgInterface.hh
@@ -38,7 +38,7 @@ class ImgInterface : public Img
public:
ImgInterface ();
/// Destructeur
- ~ImgInterface (void) {};
+ ~ImgInterface (void);
/// Transformation d'un tableau de valeurs segmentees en RGB
void doImg (const unsigned char *tabIn = 0);
/// Ajoute les coutours autour des balles trouvées
diff --git a/2005/i/robert/src/ovision/see/oconfig.cc b/2005/i/robert/src/ovision/see/oconfig.cc
index 430e4e6..6830081 100644
--- a/2005/i/robert/src/ovision/see/oconfig.cc
+++ b/2005/i/robert/src/ovision/see/oconfig.cc
@@ -28,6 +28,9 @@ OConfig::OConfig (const char *filename)
/// Destructor
OConfig::~OConfig ()
{
+ delete [] node;
+ delete [] color;
+ delete [] index;
}
/// Parse une ligne du fichier de config
@@ -110,6 +113,7 @@ OConfig::load (const char *filename)
}
parse(cut[0], cut[2]);
}
+ fclose (file);
}
/// Chargement des poids d'un reseau de neurones
diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc
index 64a372a..13afc18 100644
--- a/2005/i/robert/src/ovision/see/ovision.cc
+++ b/2005/i/robert/src/ovision/see/ovision.cc
@@ -14,10 +14,12 @@ OVision::~OVision ()
{
delete oconfig_;
delete img_;
+ delete v4l_;
delete segm_;
delete group_;
delete mag_;
delete space_;
+ delete colorTab_;
}
/// Iniialisatoin de toutes les classes
diff --git a/2005/i/robert/src/ovision/see/segm.cc b/2005/i/robert/src/ovision/see/segm.cc
index f194ce2..4afb402 100644
--- a/2005/i/robert/src/ovision/see/segm.cc
+++ b/2005/i/robert/src/ovision/see/segm.cc
@@ -40,8 +40,8 @@ Segm::segmImg (Img *img)
{
// Initialisation
unsigned char* d = img->tabData_;
- 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;
}