summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/ovision.cc
diff options
context:
space:
mode:
authorgaillaro2005-05-06 14:43:00 +0000
committergaillaro2005-05-06 14:43:00 +0000
commit9aab8a34ad597c2b46cdde3d7cdc1e44c66c9596 (patch)
tree33dcd7b5fddb67380ad517bccfe76a9cd54b1f4a /2005/i/robert/src/ovision/see/ovision.cc
parent1d6fa32f84b92e6dab641beb918cbb809ce1265b (diff)
modifs avant match vendredi
Diffstat (limited to '2005/i/robert/src/ovision/see/ovision.cc')
-rw-r--r--2005/i/robert/src/ovision/see/ovision.cc66
1 files changed, 57 insertions, 9 deletions
diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc
index 13afc18..5dd7c51 100644
--- a/2005/i/robert/src/ovision/see/ovision.cc
+++ b/2005/i/robert/src/ovision/see/ovision.cc
@@ -3,7 +3,7 @@
/// Constructeur
OVision::OVision (bool useSocket)
- : oconfig_ (0), img_ (0), colorTab_ (0), segm_ (0),
+ : oconfig_ (0), img_ (0), colorTab_ (0), segm_ (0), eraser_ (0),
group_ (0), mag_ (0), step_ (0), aim_ (Group::undefined) //map_ (0),
{
// socket_ = 0;
@@ -27,8 +27,31 @@ void
OVision::init (const Group::ZoneType aim)
{
aim_ = aim;
+ oconfig_ = new OConfig;
// Initialisation des classes
- oconfig_ = new OConfig;
+ if (aim == Group::redSkittle)
+ {
+ colorTab_ = new ColorTable ("../runtime/rc/colorTableGreen.z");
+ //oconfig_->nnInfluLum = ;
+ oconfig_->groupColor.clear ();
+ ObjectColor tmp;
+ tmp.label = "redSkittle";
+ tmp.color = 4;
+ tmp.type = Group::redSkittle;
+ oconfig_->groupColor.push_back (tmp);
+ }
+ else
+ {
+ colorTab_ = new ColorTable ("../runtime/rc/colorTableRed.z");
+ //oconfig_->nnInfluLum = ;
+ ObjectColor tmp;
+ oconfig_->groupColor.clear ();
+ tmp.label = "greenSkittle";
+ tmp.color = 4;
+ tmp.type = Group::greenSkittle;
+ oconfig_->groupColor.push_back (tmp);
+ }
+
img_ = new Img;
// Initialisation caméra
v4l_ = new Video4Linux ("/dev/video", oconfig_->width, oconfig_->height,
@@ -36,19 +59,20 @@ OVision::init (const Group::ZoneType aim)
v4l_->calibrate ();
// Prendre une image pour que la taille de l'image soit configuré
img_->load (*v4l_);
- colorTab_ = new ColorTable;
segm_ = new SegmTable (*colorTab_);
segm_->setMode (oconfig_->inputColor);
- group_ = new Group (img_, segm_);
- mag_ = new Magnifier (img_, segm_, aim_);
+ eraser_ = new Eraser (oconfig_->width, 10);
+ eraser_->init ();
+ group_ = new Group (img_, segm_, eraser_);
+ mag_ = new Magnifier (img_, segm_, eraser_, aim_);
// Mode de couleur utilisé pour les la segmentation
segm_->setMode (oconfig_->inputColor);
space_ = new Space (img_->width_, img_->height_);
// 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 (56, 155, 50, 315);
+ space_->addSetupPoint (65, 51, 50, 465);
+ space_->addSetupPoint (164, 46, -50, 465);
+ space_->setup (0.003, -2.106, 561.391);
}
/// Prends une image avec la caméra
@@ -91,6 +115,30 @@ OVision::showInfo () const
std::cout << "-------------\n" << std::endl;
}
+/// Renvoie la position de la quille dans le référentiel robot
+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 (tmpX / (tmpY+9)));
+ dist = tmpY;
+}
+
/// Renvoie la liste des quilles
std::vector<Zone>&
OVision::getSkittles () const