summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see')
-rw-r--r--2005/i/robert/src/ovision/see/Makefile.defs3
-rw-r--r--2005/i/robert/src/ovision/see/img.hh1
-rw-r--r--2005/i/robert/src/ovision/see/magnifier.cc59
-rw-r--r--2005/i/robert/src/ovision/see/magnifier.hh10
-rw-r--r--2005/i/robert/src/ovision/see/oconfig.hh1
-rw-r--r--2005/i/robert/src/ovision/see/ovision.cc19
-rw-r--r--2005/i/robert/src/ovision/see/ovision.hh6
-rw-r--r--2005/i/robert/src/ovision/see/skittle.hh5
-rw-r--r--2005/i/robert/src/ovision/see/test_ovision.cc44
9 files changed, 111 insertions, 37 deletions
diff --git a/2005/i/robert/src/ovision/see/Makefile.defs b/2005/i/robert/src/ovision/see/Makefile.defs
index c53d6b7..eaeee03 100644
--- a/2005/i/robert/src/ovision/see/Makefile.defs
+++ b/2005/i/robert/src/ovision/see/Makefile.defs
@@ -1,7 +1,7 @@
PROGRAMS += test_ovision test_img test_group test_map test_ovisiontracker test_cam test_segm test_magnifier test_ovision test_colortable test_space
LIBS += $(ovision_OBJECTS)
-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
+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 ovision.o -lz 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
@@ -24,7 +24,6 @@ test_segm: $(test_segm_OBJECTS:%.o=%.o)
test_group: $(test_group_OBJECTS:%.o=%.o)
test_magnifier: $(test_magnifier_OBJECTS:%.o=%.o)
test_ovision: $(test_ovision_OBJECTS:%.o=%.o)
- $(CXX) $(LDFLAGS) -lz $^ -o $@
test_ovisionogl: $(test_ovisionogl_OBJECTS:%.o=%.o)
test_ovisiontracker: $(test_ovisiontracker_OBJECTS:%.o=%.o)
test_map: $(test_map_OBJECTS:%.o=%.o)
diff --git a/2005/i/robert/src/ovision/see/img.hh b/2005/i/robert/src/ovision/see/img.hh
index 51bbfee..750e629 100644
--- a/2005/i/robert/src/ovision/see/img.hh
+++ b/2005/i/robert/src/ovision/see/img.hh
@@ -41,6 +41,7 @@ class Img
friend class Comm;
friend class Live;
friend class Skittle;
+ friend class OVision;
public:
/// Constructeur
diff --git a/2005/i/robert/src/ovision/see/magnifier.cc b/2005/i/robert/src/ovision/see/magnifier.cc
index c528444..66db1b4 100644
--- a/2005/i/robert/src/ovision/see/magnifier.cc
+++ b/2005/i/robert/src/ovision/see/magnifier.cc
@@ -8,13 +8,14 @@
#include "magnifier.hh"
#include "skittle.hh"
-
+
/// Constructeur
-Magnifier::Magnifier (Img *img, Segm *segm)
- : segm_ (segm), img_ (img)
+Magnifier::Magnifier (Img *img, Segm *segm, Group::ZoneType aim)
+: segm_ (segm), img_ (img), aim_ (aim), skittleList_ (0)
{
oconfig_ = OConfig::getInstance ();
itemList_ = new std::vector<Zone>[Group::nbZoneType];
+ skittleList_ = new std::vector<Skittle>;
}
/// Destructeur
@@ -29,18 +30,18 @@ Magnifier::~Magnifier (void)
/// @param type type du group à rechercher GOAL ou BALL
/// @param y coordonnees de la hauteur de la balle
/*int
-Group::GetDelta (int type, int y)
-{
- if (type == BALL)
- return (int)(25 + y*0.1);
-
- else return 3*(int)(25 + y*0.1);
-}
-*/
+ Group::GetDelta (int type, int y)
+ {
+ if (type == BALL)
+ return (int)(25 + y*0.1);
+
+ else return 3*(int)(25 + y*0.1);
+ }
+ */
/// Analyse une liste de zones
/// @param zoneList liste des zones extraites par la classe group
-void
+bool
Magnifier::analyse (std::vector<Zone> &zoneList)
{
// remise à zéro de toutes les listes
@@ -80,11 +81,24 @@ Magnifier::analyse (std::vector<Zone> &zoneList)
break;
}
}
- if (itemList_[Group::redSkittle].size () != 0)
+ skittleList_->clear ();
+ if (itemList_[aim_].size () != 0)
{
- Zone &z = itemList_[Group::redSkittle][0];
- isSkittle (z);
+ bool find = 0;
+ for (std::vector<Zone>::iterator iter = itemList_[aim_].begin ();
+ iter != itemList_[aim_].end (); ++iter)
+ {
+ Skittle *s = isSkittle (*iter);
+ if (s)
+ {
+ skittleList_->push_back (*s);
+ delete s;
+ find = 1;
+ }
+ }
+ return find;
}
+ return false;
}
@@ -111,13 +125,18 @@ Magnifier::checkIsUnique (const Zone &zone)
}
/// Test si l'objet est une quille
-bool
+Skittle*
Magnifier::isSkittle (Zone &zone)
{
- Skittle s (img_, segm_);
- s.analyse (zone, itemList_[Group::reflectBand]);
- s.show ();
- return true;
+ Skittle *s = new Skittle (img_, segm_);
+ if (s->analyse (zone, itemList_[Group::reflectBand]))
+ {
+ s->show ();
+ return s;
+ }
+ else
+ delete s;
+ return 0;
}
/// Test si l'objet est une quille rouge
diff --git a/2005/i/robert/src/ovision/see/magnifier.hh b/2005/i/robert/src/ovision/see/magnifier.hh
index b25c3ac..184b790 100644
--- a/2005/i/robert/src/ovision/see/magnifier.hh
+++ b/2005/i/robert/src/ovision/see/magnifier.hh
@@ -41,14 +41,18 @@ class Magnifier
Img *img_;
/// Liste des objects après analyse
std::vector<Zone> *itemList_;
+ /// Cible
+ Group::ZoneType aim_;
+ /// Liste de quilles
+ std::vector<Skittle> *skittleList_;
public:
/// Constructeur
- Magnifier (Img *img, Segm *segm);
+ Magnifier (Img *img, Segm *segm, Group::ZoneType aim);
/// Destructeur
~Magnifier (void);
/// Analyse une liste de zones
- void analyse (std::vector<Zone> &zoneList);
+ bool analyse (std::vector<Zone> &zoneList);
/// Affiche les zones trouvees après analyse
void showItems (const Group::ZoneType type) const;
/// Renvoie une liste d'objet
@@ -61,7 +65,7 @@ class Magnifier
/// Test si l'object s'agit d'un doublon
bool checkIsUnique (const Zone &zone);
/// Test la validité des objects
- bool isSkittle (Zone &zone);
+ Skittle* isSkittle (Zone &zone);
bool isRedSkittle (const Zone &zone) const;
bool isGreenSkittle (const Zone &zone) const;
bool isBase (const Zone &zone) const;
diff --git a/2005/i/robert/src/ovision/see/oconfig.hh b/2005/i/robert/src/ovision/see/oconfig.hh
index 783ff48..39efd18 100644
--- a/2005/i/robert/src/ovision/see/oconfig.hh
+++ b/2005/i/robert/src/ovision/see/oconfig.hh
@@ -26,6 +26,7 @@
#include <vector>
#include <string>
+
#include "image/image.hh"
struct ObjectColor
diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc
index 71f76d2..9a74c21 100644
--- a/2005/i/robert/src/ovision/see/ovision.cc
+++ b/2005/i/robert/src/ovision/see/ovision.cc
@@ -4,7 +4,7 @@
/// Constructeur
OVision::OVision (bool useSocket)
: oconfig_ (0), img_ (0), colorTab_ (0), segm_ (0),
- group_ (0), mag_ (0), step_ (0) //map_ (0),
+ group_ (0), mag_ (0), step_ (0), aim_ (Group::undefined) //map_ (0),
{
// socket_ = 0;
}
@@ -24,8 +24,9 @@ OVision::~OVision ()
/// Iniialisatoin de toutes les classes
void
-OVision::init ()
+OVision::init (const Group::ZoneType aim)
{
+ aim_ = aim;
// Initialisation des classes
oconfig_ = new OConfig;
img_ = new Img;
@@ -37,16 +38,16 @@ OVision::init ()
colorTab_ = new ColorTable;
segm_ = new SegmTable (*colorTab_);
group_ = new Group (img_, segm_);
- mag_ = new Magnifier (img_, segm_);
+ mag_ = new Magnifier (img_, segm_, aim_);
// Mode de couleur utilisé pour les la segmentation
segm_->setMode (oconfig_->inputColor);
-// space = new Space(img_->width, img_->height);
+ space_ = new Space (img_->width_, img_->height_);
// map_ = new Map (space);
// Calibration des longueurs
-// space->AddSetupPoint (314, 6, 100, 400);
-// space->AddSetupPoint (237, 224, 100, 900);
-// space->AddSetupPoint (275, 113, 100, 550);
-// space->Setup (0.00891157, 0.258144, 403.801);
+ space_->addSetupPoint (314, 6, 100, 400);
+ space_->addSetupPoint (237, 224, 100, 900);
+ space_->addSetupPoint (275, 113, 100, 550);
+ space_->setup (0.00891157, 0.258144, 403.801);
// Ouverture ou création de la table de couleur
/// Initialisation des socket_s
// socket_ = new SocketClient ("10.42.51.2" , 106560*3);
@@ -71,7 +72,7 @@ OVision::update ()
// Cherche les balles
group_->jumpPoints (oconfig_->groupColor);
// Analyse et tri la liste de zones trouvées
- mag->analyse (group->getZoneList ());
+ mag_->analyse (group_->getZoneList ());
// Parcours la liste de balles trouvées
/* if (group_->zoneListBall)
{
diff --git a/2005/i/robert/src/ovision/see/ovision.hh b/2005/i/robert/src/ovision/see/ovision.hh
index 89f78d2..f3b9339 100644
--- a/2005/i/robert/src/ovision/see/ovision.hh
+++ b/2005/i/robert/src/ovision/see/ovision.hh
@@ -43,19 +43,21 @@ class OVision
SegmTable *segm_;
Group *group_;
Magnifier *mag_;
-// Space *space_;
+ Space *space_;
// Map *map_;
// SocketClient *socket_;
Video4Linux *v4l_;
/// Nombre d'images déjà traitées
int step_;
+ ///
+ Group::ZoneType aim_;
public:
/// Constructeur
OVision (bool useSocket = false);
/// Destructeur
~OVision (void);
/// Iniialisatoin de toutes les classes
- void init ();
+ void init (const Group::ZoneType aim);
/// Prends une image avec la caméra
void takeShoot ();
/// Analyse une image
diff --git a/2005/i/robert/src/ovision/see/skittle.hh b/2005/i/robert/src/ovision/see/skittle.hh
index fb5ff77..b41d154 100644
--- a/2005/i/robert/src/ovision/see/skittle.hh
+++ b/2005/i/robert/src/ovision/see/skittle.hh
@@ -45,7 +45,7 @@ class Skittle
/// Enum pos
enum Pos {up, down, farAway, error};
/// Courbure
- double bend_;
+ Pos bend_;
/// Position de la bande réfléchissante
Pos reflectBand_;
@@ -58,6 +58,9 @@ class Skittle
bool analyse (const Zone &zone, const std::vector<Zone> &listReflectBand);
/// Affiche les infos sur la quille
void show () const;
+ /// Recupère les données
+ inline void get (Pos &standing, double &pcX, double &pcY)
+ {standing = bend_; pcX = pcX_; pcY = pcY_;}
private:
/// Recherche de la composante principale
diff --git a/2005/i/robert/src/ovision/see/test_ovision.cc b/2005/i/robert/src/ovision/see/test_ovision.cc
new file mode 100644
index 0000000..82a236c
--- /dev/null
+++ b/2005/i/robert/src/ovision/see/test_ovision.cc
@@ -0,0 +1,44 @@
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "ovision.hh"
+
+int
+main(int argv, char **argc)
+{
+ if (argv != 2)
+ {
+ std::cerr << "Usage : ./test_ovision {red, green}" << std::endl;
+ return 1;
+ }
+ std::string arg (argc[1]);
+ Group::ZoneType aim;
+ if (arg == "red")
+ aim = Group::redSkittle;
+ else if (arg == "green")
+ aim = Group::greenSkittle;
+ else
+ {
+ aim = Group::undefined;
+ std::cerr << "Echec critique !" << std::endl;
+ }
+ OVision ovision;
+ ovision.init (aim);
+ while (1)
+ {
+ // Prends une image
+ ovision.takeShoot ();
+ // Analyse une image
+ ovision.update ();
+ // Affiche d'info sur l'update
+ ovision.showInfo ();
+ // Affiche les coordonnées de la première balle
+ double x, y;
+ if (ovision.getBall (x, y))
+ std::cout << x <<"----" << y << std::endl;
+ sleep (1);
+ }
+ return 0;
+}
+