summaryrefslogtreecommitdiff
path: root/2005/i/robert
diff options
context:
space:
mode:
authorgaillaro2005-06-24 22:59:55 +0000
committergaillaro2005-06-24 22:59:55 +0000
commit1c1966cb48f0353caa284d71996524ffd63e3968 (patch)
treecd15f1c0945523ac2a08a5acd40994c84abb5598 /2005/i/robert
parent1a8df226c34078a80c4bc59be37657f23f352298 (diff)
modif pour la distance reelle de la quille
Diffstat (limited to '2005/i/robert')
-rw-r--r--2005/i/robert/src/ovision/see/magnifier.cc8
-rw-r--r--2005/i/robert/src/ovision/see/ovision.cc21
-rw-r--r--2005/i/robert/src/ovision/see/skittle.cc2
-rw-r--r--2005/i/robert/src/ovision/see/space.cc26
-rw-r--r--2005/i/robert/src/ovision/see/space.hh4
-rw-r--r--2005/i/robert/src/ovision/ui/live.cc16
-rw-r--r--2005/i/robert/src/ovision/ui/live.hh3
7 files changed, 54 insertions, 26 deletions
diff --git a/2005/i/robert/src/ovision/see/magnifier.cc b/2005/i/robert/src/ovision/see/magnifier.cc
index b61b260..8ac1eb4 100644
--- a/2005/i/robert/src/ovision/see/magnifier.cc
+++ b/2005/i/robert/src/ovision/see/magnifier.cc
@@ -69,7 +69,7 @@ Magnifier::analyse (std::vector<Zone> &zoneList)
iter->alone = !eraser_->isTooBig (*iter);
iter->small = eraser_->isTooSmall (*iter);
if (iter->partial) getPosOut (*iter);
- showZone (*iter);
+ //showZone (*iter);
//s->show ();
delete s;
find = true;
@@ -352,14 +352,14 @@ void
Magnifier::showZone (const Zone &z) const
{
std::cout << "------------------------------------------------------------------\n";
- std::cout << "<Magnifier::showZone> position : " << z.xmin << ", " << z.xmax << ", " << z.ymin << ", " << z.ymax << "\n";
+ std::cout << "<Magnifier::showZone> position image : " << z.xmin << ", " << z.xmax << ", " << z.ymin << ", " << z.ymax << "\n";
std::cout << "<Magnifier::showZone> area : " << z.area << "\n";
std::cout << "<Magnifier::showZone> small : " << z.small << "\n";
std::cout << "<Magnifier::showZone> alone : " << z.alone << "\n";
// std::cout << "<Magnifier::showZone> density: " << z.density << "\n";
// std::cout << "<Magnifier::showZone> circleUp: " << z.circleUp << "\n";
std::cout << "<Magnifier::showZone> ratio/vertical: " << z.ratio << " " << (z.vertical?"vertical":"") << "\n";
-// std::cout << "<Magnifier::showZone> orientation : " << z.pcX_ << ", " << z.pcY_ << "\n";
+ std::cout << "<Magnifier::showZone> orientation : " << z.pcX << ", " << z.pcY << "\n";
std::cout << "<Magnifier::showZone> partial : " << z.partial << "\n";
std::cout << "<Magnifier::showZone> posOut : " << z.posOut << "\n";
-}
+
diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc
index 2cbb4a1..c66d64a 100644
--- a/2005/i/robert/src/ovision/see/ovision.cc
+++ b/2005/i/robert/src/ovision/see/ovision.cc
@@ -120,26 +120,7 @@ OVision::showInfo () const
void
OVision::getLoc (Zone &zone, int &x, int &y, int &angle, int &dist)
{
- space_->getLoc (zone.ymax, zone.centerx, x, y);
- double newPcX, newPcY;
- if (zone.pcY > 0)
- {
- newPcY = - zone.pcY;
- newPcX = - zone.pcX;
- }
- else
- {
- newPcX = zone.pcX;
- newPcY = zone.pcY;
- }
- int tmpX = (int)((zone.xmax - zone.centerx) * newPcX + zone.centerx);
- int tmpY = (int)((zone.ymax - zone.centery) * newPcY + zone.centery);
- int newX, newY;
- space_->getLoc (tmpX, tmpY, newX, newY);
- angle = (int)(atan ((double)newX / ((double)newY + 90)));
- x = newX; y = newY;
- dist = (int)sqrt (y*y + x*x);
- std::cout << "<OVision::getLoc> " << " " << newX << " " << newY << " " << angle << " " << dist << "\n";
+ space_->getRealLoc (zone, x, y, angle, dist);
}
/// Renvoie la liste des quilles
diff --git a/2005/i/robert/src/ovision/see/skittle.cc b/2005/i/robert/src/ovision/see/skittle.cc
index 602f77a..22ba407 100644
--- a/2005/i/robert/src/ovision/see/skittle.cc
+++ b/2005/i/robert/src/ovision/see/skittle.cc
@@ -170,6 +170,8 @@ Skittle::analyse (Zone &zone, const std::vector<Zone> &listReflectBand)
if ((pcY_ > 0.95) || (pcY_ < -0.95))
zone.vertical = true;
else zone.vertical = false;
+ zone.pcX = pcX_;
+ zone.pcY = pcY_;
// if ((zone.centery > 140) && (pcX_ > 0.98) && (zone.density > 0.7)
// && (zone.density < 0.85) && (zone.ratio > 0.6) && (zone.ratio < 0.8))
// return false;
diff --git a/2005/i/robert/src/ovision/see/space.cc b/2005/i/robert/src/ovision/see/space.cc
index c58268d..efba67b 100644
--- a/2005/i/robert/src/ovision/see/space.cc
+++ b/2005/i/robert/src/ovision/see/space.cc
@@ -161,3 +161,29 @@ Space::getPos (const double locX, const double locY, const double posRobotX, con
posY = posRobotY + locX*sinus + locY*cosinus;
}
+/// Give Real Location dist and angle
+void
+Space::getRealLoc (Zone &zone, int &x, int &y, int &angle, int &dist)
+{
+ // we want a pcY positive to sub it to centery
+ double newPcX, newPcY;
+ if (zone.pcY < 0)
+ {
+ newPcY = - zone.pcY;
+ newPcX = - zone.pcX;
+ }
+ else
+ {
+ newPcX = zone.pcX;
+ newPcY = zone.pcY;
+ }
+ // we are looking for the bottom of the object
+ int tmpX = (int)((zone.xmax - zone.centerx) * newPcX + zone.centerx);
+ int tmpY = (int)((zone.ymax - zone.centery) * newPcY + zone.centery);
+ std::cout << "<Space::getRealLoc> : "<< tmpX << " " << tmpY << "\n";
+ int newX, newY;
+ getLoc (tmpX, tmpY, newX, newY);
+ angle = (int)(atan ((double)newX / ((double)newY + 90)));
+ x = newX; y = newY;
+ dist = (int)sqrt (y*y + x*x);
+}
diff --git a/2005/i/robert/src/ovision/see/space.hh b/2005/i/robert/src/ovision/see/space.hh
index d848979..7e9f7e8 100644
--- a/2005/i/robert/src/ovision/see/space.hh
+++ b/2005/i/robert/src/ovision/see/space.hh
@@ -54,8 +54,10 @@ class Space
void getLoc (const int locImgX, const int locImgY, int &locX, int &locY_);
void getLoc (const int locImgX, const int locImgY, double &locX, double &locY_);
/// Donne la position reelle sur la table de la balle
- void getPos (const double locX, const double locY_, const double posRobotX,
+ void getPos (const double locX, const double locY, const double posRobotX,
const double posRobotY, const double angleRobot, double &posX, double &posY);
+ /// Give Real Location dist and angle
+ void getRealLoc (Zone &zone, int &x, int &y, int &angle, int &dist);
/// Ajoute un point pour l'etalonnage
void addSetupPoint (const int x, const int y, const int distx, const int disty);
/// Chargement des points a partir d'un fichier
diff --git a/2005/i/robert/src/ovision/ui/live.cc b/2005/i/robert/src/ovision/ui/live.cc
index 4722b3a..c608c8f 100644
--- a/2005/i/robert/src/ovision/ui/live.cc
+++ b/2005/i/robert/src/ovision/ui/live.cc
@@ -22,7 +22,7 @@
/// Constructeur
/// @param *filename nom de l'image a utiliser
Live::Live (const unsigned nbImg, const ImageInput imgInput)
- : reader_ (0), db_ (0), st_ (0), colorToFind_ (-1), group (0),
+ : reader_ (0), db_ (0), st_ (0), colorToFind_ (-1), group (0),
width_ (640), height_ (480), imgInput_ (imgInput)
{
if (nbImg < 6) nbImg_ = 6;
@@ -94,6 +94,12 @@ Live::init (const Image::PixelFormat pf, const char *filename)
eraser = new Eraser (oconfig->width, 10);
eraser->init ();
mag = new Magnifier (img, segm, eraser, Group::ZoneType (oconfig->uiGroupToDisplay));
+ space = new Space (img->width_, img->height_);
+ // Calibration des longueurs
+ space->addSetupPoint (56, 155, 50, 315);
+ space->addSetupPoint (65, 51, 50, 465);
+ space->addSetupPoint (164, 46, -50, 465);
+ space->setup (0.003, -2.106, 561.391);
segmAndGroup ();
// Affichage de l'image pilote avec la couleur d'aquisition et en RGB
tex[1] = loadImage (img->width_, img->height_, data[0], tex[1]);
@@ -182,6 +188,14 @@ Live::segmAndGroup (const int numColorToShow)
group->jumpPoints (oconfig->groupColor);
mag->analyse (group->getZoneList ());
list = mag->getItemList ((Group::ZoneType)oconfig->uiGroupToDisplay);
+ int x, y, angle, dist;
+ for (std::vector<Zone>::iterator iter = list.begin ();
+ iter != list.end (); ++iter)
+ {
+ mag->showZone (*iter);
+ space->getRealLoc (*iter, x, y, angle, dist);
+ std::cout << "<Live::segmAndGroup> position réelle : "<< x << " " << y << " " << angle << " " << dist << "\n";
+ }
}
// Création de l'image des groupes
segm->segmImg (img);
diff --git a/2005/i/robert/src/ovision/ui/live.hh b/2005/i/robert/src/ovision/ui/live.hh
index c9137a8..bc4a5dc 100644
--- a/2005/i/robert/src/ovision/ui/live.hh
+++ b/2005/i/robert/src/ovision/ui/live.hh
@@ -30,6 +30,7 @@
#include "ovision/see/oconfig.hh"
#include "ovision/see/group.hh"
#include "ovision/see/magnifier.hh"
+#include "ovision/see/space.hh"
#include "socket/socket_text.hh"
#include "data/data_buffer.hh"
@@ -67,6 +68,8 @@ class Live
Group *group;
/// classe magnifier
Magnifier *mag;
+ /// classe space
+ Space *space;
/// nom de l'image courante
char fname[100];
/// taille image