summaryrefslogtreecommitdiff
path: root/2005/i
diff options
context:
space:
mode:
Diffstat (limited to '2005/i')
-rw-r--r--2005/i/robert/src/ovision/see/Makefile.defs5
-rw-r--r--2005/i/robert/src/ovision/see/hotelling.cc2
-rw-r--r--2005/i/robert/src/ovision/see/hpoint.hh1
-rw-r--r--2005/i/robert/src/ovision/see/img.hh1
-rw-r--r--2005/i/robert/src/ovision/see/magnifier.cc47
-rw-r--r--2005/i/robert/src/ovision/see/oconfig.cc4
-rw-r--r--2005/i/robert/src/ovision/see/skittle.cc132
-rw-r--r--2005/i/robert/src/ovision/see/skittle.hh61
-rw-r--r--2005/i/robert/src/ovision/ui/Makefile.defs7
9 files changed, 213 insertions, 47 deletions
diff --git a/2005/i/robert/src/ovision/see/Makefile.defs b/2005/i/robert/src/ovision/see/Makefile.defs
index 0f0e61a..07430d3 100644
--- a/2005/i/robert/src/ovision/see/Makefile.defs
+++ b/2005/i/robert/src/ovision/see/Makefile.defs
@@ -1,8 +1,7 @@
PROGRAMS += test_ovision test_img test_group test_map test_ovisiontracker test_cam test_segm test_magnifier test_ovision test_colortable
LIBS += $(ovision_OBJECTS)
-LDFLAGS= -Wall -g -fprofile-arcs -ftest-coverage -fmessage-length=0
-ovision_OBJECTS = convertImg.o img.o oconfig.o segmTable.o hotelling.o segm.o imgInterface.o colorTable.o segmTable.o segmLearn.o group.o magnifier.o #space.o map.o
+ovision_OBJECTS = convertImg.o img.o oconfig.o segmTable.o hotelling.o segm.o imgInterface.o colorTable.o segmTable.o segmLearn.o group.o magnifier.o skittle.o #space.o map.o
test_img_OBJECTS = test_img.o img.o imgInterface.o oconfig.o $(image_OBJECTS)
test_hotelling_OBJECTS = test_hotelling.o hotelling.o oconfig.o
@@ -15,7 +14,7 @@ test_map_OBJECTS = test_map.o $(ovision_OBJECTS) $(image_OBJECTS)
test_dist_OBJECTS = test_dist.o $(ovision_OBJECTS)
test_colortable_OBJECTS = test_colortable.o oconfig.o segmTable.o imgInterface.o img.o segm.o segmLearn.o colorTable.o $(image_OBJECTS)
test_group_OBJECTS = test_group.o group.o img.o segm.o segmLearn.o oconfig.o imgInterface.o $(image_OBJECTS)
-test_magnifier_OBJECTS = test_magnifier.o hotelling.o magnifier.o group.o img.o segm.o segmLearn.o oconfig.o imgInterface.o $(image_OBJECTS)
+test_magnifier_OBJECTS = test_magnifier.o hotelling.o magnifier.o group.o img.o segm.o segmLearn.o oconfig.o imgInterface.o skittle.o $(image_OBJECTS)
test_img: $(test_img_OBJECTS:%.o=%.o)
test_hotelling: $(test_hotelling_OBJECTS:%.o=%.o)
diff --git a/2005/i/robert/src/ovision/see/hotelling.cc b/2005/i/robert/src/ovision/see/hotelling.cc
index c15ba0b..dbd0e72 100644
--- a/2005/i/robert/src/ovision/see/hotelling.cc
+++ b/2005/i/robert/src/ovision/see/hotelling.cc
@@ -2,6 +2,8 @@
// robert - Programme du robot APBteam
// Copyright (C) 2005 Olivier Gaillard
+/// @file hotelling.cc Detecte l'orientation principale d'une masse de données
+
#include <iostream>
#include <math.h>
diff --git a/2005/i/robert/src/ovision/see/hpoint.hh b/2005/i/robert/src/ovision/see/hpoint.hh
index bc4d54e..d01d8e7 100644
--- a/2005/i/robert/src/ovision/see/hpoint.hh
+++ b/2005/i/robert/src/ovision/see/hpoint.hh
@@ -25,6 +25,7 @@
#include <math.h>
+/// Points utilisées pour la transformée de Hotelling
class Hpoint
{
double p_[2];
diff --git a/2005/i/robert/src/ovision/see/img.hh b/2005/i/robert/src/ovision/see/img.hh
index ac5fd14..51bbfee 100644
--- a/2005/i/robert/src/ovision/see/img.hh
+++ b/2005/i/robert/src/ovision/see/img.hh
@@ -40,6 +40,7 @@ class Img
friend class Segm;
friend class Comm;
friend class Live;
+ friend class Skittle;
public:
/// Constructeur
diff --git a/2005/i/robert/src/ovision/see/magnifier.cc b/2005/i/robert/src/ovision/see/magnifier.cc
index c7d5dc0..e34cdd6 100644
--- a/2005/i/robert/src/ovision/see/magnifier.cc
+++ b/2005/i/robert/src/ovision/see/magnifier.cc
@@ -2,10 +2,12 @@
// robert - Programme du robot APBteam
// Copyright (C) 2005 Olivier Gaillard
+/// @file magnifier.cc Filtre la liste d'objets trouvées
+
#include <iostream>
#include "magnifier.hh"
-#include "hotelling.hh"
+#include "skittle.hh"
/// Constructeur
Magnifier::Magnifier (Img *img, Segm *segm)
@@ -75,8 +77,11 @@ Magnifier::analyse (const std::vector<Zone> &zoneList)
break;
}
}
- Zone &z = itemList_[Group::redSkittle][0];
- isSkittle (z);
+ if (itemList_[Group::redSkittle].size () != 0)
+ {
+ Zone &z = itemList_[Group::redSkittle][0];
+ isSkittle (z);
+ }
}
@@ -107,40 +112,8 @@ Magnifier::checkIsUnique (const Zone &zone)
bool
Magnifier::isSkittle (Zone &zone)
{
- // Agrandissement de la zone de recherche
- const int grow = 20;
- int ymin = (zone.ymin - grow);
- ymin = (ymin > 0) ? ymin : 0;
- int ymax = (zone.ymax + grow);
- ymax = (ymax < img_->height_) ? ymax : img_->height_;
- int xmin = (zone.xmin - grow);
- xmin = (xmin > 0) ? xmin : 0;
- int xmax = (zone.xmax + grow);
- xmax = (xmax < img_->width_) ? xmax : img_->width_;
- // Parcours d'une partie des pixels de l'image
- int tmpY;
- int jump = oconfig_->jumpPointDist/5;
- if (!jump) jump = 1;
- std::vector<Hpoint> l;
- for (int y = zone.ymin - grow; y < zone.ymax + grow; y += jump)
- {
- tmpY = y*img_->width_;
- for (int x=zone.xmin - grow; x < zone.xmax + grow; x += jump)
- if (segm_->giveColor (img_->tabData_ + ((tmpY + x) * 3), true, true) == zone.color)
- {
- Hpoint h (x, y);
- l.push_back (h);
- }
- }
- // Calcul de la composante principale
- for (std::vector<Hpoint>::iterator iter = l.begin (); iter != l.end (); ++iter)
- std::cout << (*iter)[0] << " " << (*iter)[1] << std::endl;
- Hotelling hote (l);
- hote.eigenVectors ();
- double i, j;
- hote.getPC (i, j);
- hote.show ();
- std::cout << "PC : " << i << " " << j << std::endl;
+ Skittle s (img_, segm_);
+ s.analyse (zone);
return true;
}
diff --git a/2005/i/robert/src/ovision/see/oconfig.cc b/2005/i/robert/src/ovision/see/oconfig.cc
index 663337a..fd96d12 100644
--- a/2005/i/robert/src/ovision/see/oconfig.cc
+++ b/2005/i/robert/src/ovision/see/oconfig.cc
@@ -2,7 +2,7 @@
// robert - Programme du robot APBteam
// Copyright (C) 2005 Olivier Gaillard
-/// @file config.cc Charge le fichier config et distribue les variables
+/// @file oconfig.cc Charge le fichier config et distribue les variables
#include <iostream>
#include <fstream>
@@ -36,7 +36,7 @@ OConfig::~OConfig()
void
OConfig::parse(const char *var, const char *arg)
{
- if (!arg) throw "OConfig::parse : Error during config file parsing";
+ if (!arg) return;
std::string varName (var);
if (varName == "Cam_color")
{
diff --git a/2005/i/robert/src/ovision/see/skittle.cc b/2005/i/robert/src/ovision/see/skittle.cc
new file mode 100644
index 0000000..45462c1
--- /dev/null
+++ b/2005/i/robert/src/ovision/see/skittle.cc
@@ -0,0 +1,132 @@
+// skittle.cc - Classe Skittle
+// robert - Programme du robot APBteam
+// Copyright (C) 2005 Olivier Gaillard
+
+/// @file skittle.cc Reconnaissance des objets quilles
+
+#include <iostream>
+
+#include "skittle.hh"
+#include "hotelling.hh"
+
+/// Constructeur
+Skittle::Skittle (Img *img, Segm *segm)
+ : segm_ (segm), img_ (img)
+{
+ oconfig_ = OConfig::getInstance ();
+}
+
+/// Destructeur
+Skittle::~Skittle (void)
+{
+}
+
+/// Recherche de la composante principale
+void
+Skittle::pca (Zone &zone)
+{
+ // Agrandissement de la zone de recherche
+ const int grow = 30;
+ int ymin = (zone.ymin - grow);
+ ymin = (ymin > 0) ? ymin : 0;
+ int ymax = (zone.ymax + grow);
+ ymax = (ymax < img_->height_) ? ymax : img_->height_;
+ int xmin = (zone.xmin - grow);
+ xmin = (xmin > 0) ? xmin : 0;
+ int xmax = (zone.xmax + grow);
+ xmax = (xmax < img_->width_) ? xmax : img_->width_;
+ /// Initialisation du saut de point
+ int jump = oconfig_->jumpPointDist/5;
+ if (!jump) jump = 1;
+ // Parcours d'une partie des pixels de l'image
+ int tmpY;
+ std::vector<Hpoint> l;
+ for (int y = zone.ymin - grow; y < zone.ymax + grow; y += jump)
+ {
+ tmpY = y*img_->width_;
+ for (int x=zone.xmin - grow; x < zone.xmax + grow; x += jump)
+ if (segm_->giveColor (img_->tabData_ + ((tmpY + x) * 3), true, true) == zone.color)
+ {
+ Hpoint h (x, y);
+ l.push_back (h);
+ }
+ }
+ // Calcul de la composante principale
+ for (std::vector<Hpoint>::iterator iter = l.begin (); iter != l.end (); ++iter)
+ std::cout << (*iter)[0] << " " << (*iter)[1] << std::endl;
+ Hotelling hote (l);
+ hote.eigenVectors ();
+ double i, j;
+ hote.getPC (i, j);
+ hote.show ();
+ std::cout << "PC : " << i << " " << j << std::endl;
+}
+
+/// Utilisé pour la recherche de la courbure, cherche le point le plus haut
+int
+Skittle::climb (const int startX, int startY, const int color)
+{
+ while (segm_->giveColor (img_->tabData_ + ((startY*img_->width_ + startX) * 3), true, true) == color)
+ {
+// std::cout << startX << " " << startY << std::endl;
+ --startY;
+ }
+ return startY;
+}
+
+/// Recherche de du côté de la courbure
+Skittle::BendType
+Skittle::bend (Zone &zone)
+{
+ /// Border
+ const int border = 20;
+ /// Initialisation du saut de point
+ int jump = oconfig_->jumpPointDist/5;
+ if (!jump) jump = 1;
+ /// Initialisation du point de départ
+ const int startY = (int)(zone.ymin + (zone.ymax - zone.ymin) * 0.25);
+ /// Point supérieur de la quille
+ int upperPoint;
+ /// Recherche du premier et du dernier point
+ int firstPoint = climb (zone.xmin + border, startY, zone.color);
+ int lastPoint = climb (zone.xmax - border, startY, zone.color);
+ int limitPoint = firstPoint > lastPoint ? firstPoint : lastPoint;
+ std::cout << firstPoint << " " << lastPoint << " " << limitPoint << std::endl;
+ int above = 0; int below = 0;
+ /// Parcours des autres points
+ for (int i = zone.xmin + border + jump; i < zone.xmax - border - jump; i+=jump)
+ {
+ upperPoint = climb (i, startY, zone.color);
+ std::cout << upperPoint << " ";
+ if (upperPoint > limitPoint) ++below;
+ else ++above;
+ }
+ std::cout << std::endl;
+ const int score = (int)((zone.xmax - zone.xmin - 2*border) / jump * 0.90) - 2;
+
+ BendType bending = error;
+ if (above > score) bending = up;
+ else if (below > score) bending = down;
+
+ std::cout << "courb " << bending << std::endl;
+ return bending;
+}
+
+/// Analyse la zone
+bool
+Skittle::analyse (Zone &zone)
+{
+ // group est partiel ?
+ // if (zone.partial)
+ // quille verticale sur l'image ?
+ if ((zone.ymax - zone.ymin)/(double)(zone.xmax - zone.xmin) > 1.1)
+ {
+ std::cout << "vertical !!!" << std::endl;
+ // debout ou couché ?
+ bend (zone);
+ }
+ else
+ // calcul de l'orientation
+ pca (zone);
+ return true;
+}
diff --git a/2005/i/robert/src/ovision/see/skittle.hh b/2005/i/robert/src/ovision/see/skittle.hh
new file mode 100644
index 0000000..3ff458e
--- /dev/null
+++ b/2005/i/robert/src/ovision/see/skittle.hh
@@ -0,0 +1,61 @@
+// 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 skittle_h
+#define skittle_h
+
+#include <vector>
+
+#include "segm.hh"
+#include "oconfig.hh"
+#include "group.hh"
+#include "img.hh"
+
+/// Reconnaissance des objets quilles
+class Skittle
+{
+ /// Classe segmentation
+ Segm *segm_;
+ /// Classe oconfig
+ OConfig *oconfig_;
+ /// Classe img
+ Img *img_;
+
+ public:
+ /// Constructeur
+ Skittle (Img *img, Segm *segm);
+ /// Destructeur
+ ~Skittle (void);
+ /// Analyse d'une zone
+ bool analyse (Zone &zone);
+ /// Recherche de la composante principale
+ void pca (Zone &zone);
+ /// Recherche de du côté de la courbure
+ enum BendType {up, down, error};
+ BendType bend (Zone &zone);
+ /// Utilisé pour la recherche de la courbure, cherche le point le plus haut
+ int climb (const int startX, const int startY, const int color);
+
+ private:
+};
+
+#endif // skittle_h
diff --git a/2005/i/robert/src/ovision/ui/Makefile.defs b/2005/i/robert/src/ovision/ui/Makefile.defs
index 8657716..343e45f 100644
--- a/2005/i/robert/src/ovision/ui/Makefile.defs
+++ b/2005/i/robert/src/ovision/ui/Makefile.defs
@@ -1,12 +1,9 @@
PROGRAMS += adjust ui liveView
-LIBS += adjust.a
LIBSGL= -L/usr/X11R6/lib -lGL -lGLU -lglut
LIBNCURSES=-lmenu -lncurses
-CXXFLAGS = -Wall -g
-LDFLAGS = -L/usr/pkg/lib
-adjust_OBJECTS = adjust.o comm.o img.o imgInterface.o image.o group.o segm.o segmLearn.o oconfig.o convertImg.o magnifier.o live.o $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS)
-liveView_OBJECTS = liveView.o live.o img.o imgInterface.o image.o group.o segm.o segmLearn.o oconfig.o convertImg.o magnifier.o $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS)
+adjust_OBJECTS = adjust.o comm.o live.o $(ovision_OBJECTS) $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS)
+liveView_OBJECTS = liveView.o live.o $(ovision_OBJECTS) $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS)
ui_OBJECTS = ui.o mainui.o oconfig.o group.o segm.o
ui: $(ui_OBJECTS:%.o=%.o)