From 3a3f8be88bca27db95a06c78f979f3a4a2803aa3 Mon Sep 17 00:00:00 2001 From: gaillaro Date: Sat, 23 Apr 2005 20:37:12 +0000 Subject: mise à jour de l'interface ovision --- 2005/i/robert/src/ovision/see/magnifier.cc | 18 +++++++++++------- 2005/i/robert/src/ovision/see/magnifier.hh | 4 ++-- 2005/i/robert/src/ovision/see/ovision.cc | 15 ++++++--------- 2005/i/robert/src/ovision/see/ovision.hh | 6 +++--- 2005/i/robert/src/ovision/see/skittle.cc | 14 +++++++------- 2005/i/robert/src/ovision/see/skittle.hh | 4 ++-- 6 files changed, 31 insertions(+), 30 deletions(-) (limited to '2005') diff --git a/2005/i/robert/src/ovision/see/magnifier.cc b/2005/i/robert/src/ovision/see/magnifier.cc index f26e367..82485b4 100644 --- a/2005/i/robert/src/ovision/see/magnifier.cc +++ b/2005/i/robert/src/ovision/see/magnifier.cc @@ -88,19 +88,23 @@ Magnifier::analyse (std::vector &zoneList) bool Magnifier::scan () { + bool hasChanged = false; std::vector *newList = new std::vector[Group::nbZoneType]; for (int i=0; i ::iterator iter = itemList_[i].begin (); iter != itemList_[i].end (); ++iter) { if (!checkIsUnique (*iter, newList)) + { + hasChanged = true; continue; + } add (*iter, newList); } // delete [] itemList_; itemList_ = newList; } - return false; + return hasChanged; } void @@ -132,8 +136,8 @@ Magnifier::add (Zone &zone, std::vector *list) bool isInside (const Zone &z1, const Zone &z2) { - const int maxOut = 300; - int out = 0; +// const int maxOut = 300; +// int out = 0; // test si le centre est à l'intérieur if ((z1.centerx <= z2.xmax) && (z1.centerx >= z2.xmin) && (z1.centery <= z2.ymax) && (z1.centery >= z2.ymin)) @@ -246,11 +250,11 @@ Magnifier::addItem (Zone &zone, std::vector *list) void Magnifier::showItems (const Group::ZoneType type) const { - std::cout << "Items :\n"; + std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; + std::cout << Group::translateToColorName (type) << "\n"; for (std::vector::const_iterator iter = itemList_[type].begin (); iter != itemList_[type].end (); ++iter) - std::cout << (int)iter->id << " " << iter->xmin << " " << iter->xmax << " " - << iter->ymin << " " << iter->ymax << "\n"; - std::cout << std::endl; + showZone (*iter); + std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; } diff --git a/2005/i/robert/src/ovision/see/magnifier.hh b/2005/i/robert/src/ovision/see/magnifier.hh index 464e20f..58e05de 100644 --- a/2005/i/robert/src/ovision/see/magnifier.hh +++ b/2005/i/robert/src/ovision/see/magnifier.hh @@ -64,14 +64,14 @@ class Magnifier private: /// Ajout d'un objet void addItem (Zone &zone, std::vector *list); + void add (Zone &zone, std::vector *list); /// Test si l'object s'agit d'un doublon bool checkIsUnique (const Zone &zone, std::vector *list); + bool scan (); /// Test si les zones sont liées bool areBound (const Zone &z1, const Zone &z2); /// Test la validité des objects Skittle* isSkittle (Zone &zone); - void add (Zone &zone, std::vector *list); - bool scan (); 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/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc index d6a8b0b..126c28a 100644 --- a/2005/i/robert/src/ovision/see/ovision.cc +++ b/2005/i/robert/src/ovision/see/ovision.cc @@ -47,8 +47,7 @@ OVision::init (const Group::ZoneType aim) space_->addSetupPoint (237, 224, 100, 900); space_->addSetupPoint (275, 113, 100, 550); space_->setup (0.00891157, 0.258144, 403.801); -} - + /// Prends une image avec la caméra void OVision::takeShoot () @@ -84,18 +83,16 @@ OVision::showInfo () const std::cout << "-----------------------------------------------------------------" << std::endl; std::cout << "image n°" << step_ << std::endl; // Info sur les zones trouvées -// group_->showZones(); -// mag_->showItems (Group::redSkittle); + mag_->showItems (aim_); std::cout << "-------------\n" << std::endl; std::cout << "-------------\n" << std::endl; } -/// Renvoie la position -bool -OVision::getBall (double &x, double &y) const +/// Renvoie la liste des quilles +std::vector& +OVision::getSkittles () const { - return false; -// return map_->GetCurBallPos (x, y); + return mag_->getItemList (aim_); } /// Renvoie le pointeur sur Video4Linux diff --git a/2005/i/robert/src/ovision/see/ovision.hh b/2005/i/robert/src/ovision/see/ovision.hh index f3b9339..eddd7be 100644 --- a/2005/i/robert/src/ovision/see/ovision.hh +++ b/2005/i/robert/src/ovision/see/ovision.hh @@ -44,7 +44,7 @@ class OVision Group *group_; Magnifier *mag_; Space *space_; -// Map *map_; + // Map *map_; // SocketClient *socket_; Video4Linux *v4l_; /// Nombre d'images déjà traitées @@ -66,8 +66,8 @@ class OVision void sendImg (); /// Affiche d'info sur l'update void showInfo () const; - /// Renvoie la position - bool getBall (double &x, double &y) const; + /// Renvoie la liste des quilles + std::vector& OVision::getSkittles () const; /// Renvoie le pointeur sur Video4Linux Video4Linux &getVideo4Linux () const; }; diff --git a/2005/i/robert/src/ovision/see/skittle.cc b/2005/i/robert/src/ovision/see/skittle.cc index 047455e..f50705d 100644 --- a/2005/i/robert/src/ovision/see/skittle.cc +++ b/2005/i/robert/src/ovision/see/skittle.cc @@ -43,7 +43,7 @@ Skittle::pca (const Zone &zone) for (int x = xmin; x < xmax; x += jump) if (segm_->giveColor (img_->tabData_ + ((tmpY + x) * 3), true, true) == zone.color) { - *f2 << x << " " << y << std::endl; +// *f2 << x << " " << y << std::endl; Hpoint h (x, y); l.push_back (h); } @@ -62,7 +62,7 @@ Skittle::climb (const int startX, int startY, const int color) && (startY > 0)) { --startY; - *f << startX << " " << startY << "\n"; +// *f << startX << " " << startY << "\n"; } return startY; } @@ -74,7 +74,7 @@ Skittle::whereIsReflectBand (const Zone &zone, const std::vector &listRefl const double minAreaRatio = 0.1; const double maxAreaRatio = 0.4; // Test les variables de composantes principales + liste transmise - if (pcX_ || !pcY_ || listReflectBand.size ()) + if (!pcX_ || !pcY_ || listReflectBand.size ()) return error; // Analyse de la taille if (zone.area < minAreaRatio || zone.area > maxAreaRatio) // valeur réelle 0.2 @@ -151,8 +151,8 @@ bool Skittle::analyse (Zone &zone, const std::vector &listReflectBand) { // delete f; delete f2; - f = new std::ofstream ("data", std::ios_base::trunc); - f2 = new std::ofstream ("data2", std::ios_base::trunc); +// f = new std::ofstream ("data", std::ios_base::trunc); +// f2 = new std::ofstream ("data2", std::ios_base::trunc); // group est partiel ? // if (zone.partial) // quille verticale sur l'image ? @@ -180,8 +180,8 @@ Skittle::analyse (Zone &zone, const std::vector &listReflectBand) else zone.alone = false; - f->close (); - f2->close (); +// f->close (); +// f2->close (); return true; } diff --git a/2005/i/robert/src/ovision/see/skittle.hh b/2005/i/robert/src/ovision/see/skittle.hh index 678d3b7..0fb5de4 100644 --- a/2005/i/robert/src/ovision/see/skittle.hh +++ b/2005/i/robert/src/ovision/see/skittle.hh @@ -25,7 +25,7 @@ #include #include -#include +//#include #include "segm.hh" #include "oconfig.hh" @@ -53,7 +53,7 @@ class Skittle /// Position de la bande réfléchissante Pos reflectBand_; - std::ofstream *f, *f2; +// std::ofstream *f, *f2; public: /// Constructeur -- cgit v1.2.3