summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/ovision.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see/ovision.cc')
-rw-r--r--2005/i/robert/src/ovision/see/ovision.cc131
1 files changed, 131 insertions, 0 deletions
diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc
new file mode 100644
index 0000000..71f76d2
--- /dev/null
+++ b/2005/i/robert/src/ovision/see/ovision.cc
@@ -0,0 +1,131 @@
+#include "ovision.hh"
+#include <iostream>
+
+/// Constructeur
+OVision::OVision (bool useSocket)
+ : oconfig_ (0), img_ (0), colorTab_ (0), segm_ (0),
+ group_ (0), mag_ (0), step_ (0) //map_ (0),
+{
+// socket_ = 0;
+}
+
+/// Destructeur
+OVision::~OVision ()
+{
+ delete oconfig_;
+ delete img_;
+ delete segm_;
+ delete group_;
+ delete mag_;
+// delete map_;
+// delete space_;
+// delete socket_;
+}
+
+/// Iniialisatoin de toutes les classes
+void
+OVision::init ()
+{
+ // Initialisation des classes
+ oconfig_ = new OConfig;
+ img_ = new Img;
+ // Initialisation caméra
+ v4l_ = new Video4Linux ("/dev/video", oconfig_->inputColor);
+ v4l_->calibrate ();
+ // Prendre une image pour que la taille de l'image soit configuré
+ img_->load (*v4l_);
+ colorTab_ = new ColorTable;
+ segm_ = new SegmTable (*colorTab_);
+ group_ = new Group (img_, segm_);
+ mag_ = new Magnifier (img_, segm_);
+ // Mode de couleur utilisé pour les la segmentation
+ segm_->setMode (oconfig_->inputColor);
+// 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);
+ // Ouverture ou création de la table de couleur
+ /// Initialisation des socket_s
+ // socket_ = new SocketClient ("10.42.51.2" , 106560*3);
+ // socket_->Init ();
+
+ // std::cout << "Chargement OVision ................ OK" << std::endl;
+}
+
+/// Prends une image avec la caméra
+void
+OVision::takeShoot ()
+{
+ img_->load (*v4l_);
+}
+
+/// Analyse une image
+void
+OVision::update ()
+{
+ // Compteur du nombre d'image traité
+ step_++;
+ // Cherche les balles
+ group_->jumpPoints (oconfig_->groupColor);
+ // Analyse et tri la liste de zones trouvées
+ mag->analyse (group->getZoneList ());
+ // Parcours la liste de balles trouvées
+ /* if (group_->zoneListBall)
+ {
+ int x,y;
+ x = group_->zoneListBall->centerx;
+ y = img_->height - group_->zoneListBall->centery;
+ space->GetLoc (x, y, x, y);
+ }
+ */
+ // Mets à jour la map_
+ /* map_->AddBallsToMap (group_);
+ double balX, balY;
+ if (map_->GetCurBallPos (balX, balY))
+ std::cout << "Balle Courante: " << balX << " " << balY << std::endl;
+ if (map_->IsTree ())
+ {
+ double treeX, treeY;
+ map_->GetTreePos (treeX, treeY);
+ std::cout << "Tree: " << treeX << " " << treeY << std::endl;
+ }
+ */
+}
+
+/// Affiche d'info sur l'update
+void
+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);
+ std::cout << "-------------\n" << std::endl;
+ std::cout << "-------------\n" << std::endl;
+}
+
+/// Renvoie la position
+bool
+OVision::getBall (double &x, double &y) const
+{
+ return false;
+// return map_->GetCurBallPos (x, y);
+}
+
+/// Renvoie le pointeur sur Video4Linux
+Video4Linux &
+OVision::getVideo4Linux () const
+{
+ return *v4l_;
+}
+
+/// Envoie l'image par socket_
+void
+OVision::sendImg ()
+{
+// socket__->Send (img_->tabData);
+}