summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/test_ovision_tracker.cc
diff options
context:
space:
mode:
Diffstat (limited to '2004/i/nono/src/ovision/test_ovision_tracker.cc')
-rw-r--r--2004/i/nono/src/ovision/test_ovision_tracker.cc118
1 files changed, 118 insertions, 0 deletions
diff --git a/2004/i/nono/src/ovision/test_ovision_tracker.cc b/2004/i/nono/src/ovision/test_ovision_tracker.cc
new file mode 100644
index 0000000..393dca8
--- /dev/null
+++ b/2004/i/nono/src/ovision/test_ovision_tracker.cc
@@ -0,0 +1,118 @@
+// test_ovision_tracker.cc
+// nono - programme du robot 2004. {{{
+//
+// Copyright (C) 2004 Nicolas Schodet et Olivier Gaillard
+//
+// Robot APB Team/Efrei 2004.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+#include "video4linux/video4linux.h"
+#include "map.h"
+#include "oconfig.h"
+#include "group.h"
+#include "space.h"
+#include "motor/motor.h"
+#include "motor/movement_types.h"
+#include "motor/goto_tracker.h"
+
+int
+main ()
+{
+ try
+ {
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /// Initialisation des classes
+ OConfig oconfig("rc/vision.conf");
+
+ Img img;
+ Video4Linux::ColorSpace cs;
+ cs = Video4Linux::rgb;
+ Video4Linux v4l("/dev/video", cs, 55000);
+ v4l.calibrate ();
+
+ Space space(img.width, img.height, &oconfig);
+ space.AddSetupPoint (230, 16, 30, 300);
+ space.AddSetupPoint (208, 168, 40, 600);
+ space.AddSetupPoint (201, 230, 50, 900);
+ space.Setup ();
+
+ SegmNN segmNN(&img, &oconfig);
+ segmNN.BuildNN(oconfig.nn_NbCouleurs, LOAD_FROM_FILE);
+
+ Group group(&img, &segmNN);
+
+ Map map(&oconfig, &space);
+ /////////////////////////////////////////////////////////////////////////////////////////
+
+ // Paramètre les moteurs.
+ Motor m;
+ m.go ();
+ GotoTracker *tracker = new GotoTracker ();
+ Movement *mov = new MovementGoto (tracker);
+ m.addMovement (mov);
+
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /// Prends une image a partir de la camera et l'analyse
+ //char filename[30];
+ int i = 0;
+ while (i < 3)
+ {
+ std::cout << "-----------------------------------------------------------------" << std::endl;
+ std::cout << "image n°" << i << std::endl;
+ img.load(v4l);
+ std::cout << "image n°" << i << " loaded" << std::endl;
+ //img.load(v4l);
+ //sprintf(filename, "test%i.rgb", i);
+ //img.WriteRGB(filename);
+ segmNN.Segm();
+
+ group.JumpPoints(oconfig.groupColor);
+ group.ShowZones();
+ std::cout << "-------------\n" << std::endl;
+ if (group.zoneListBall)
+ {
+ int x,y;
+ double angle;
+ x = group.zoneListBall->centerx - img.width/2;
+ y = img.height - group.zoneListBall->centery;
+ std::cout << x << " " << y << std::endl;
+ space.GetLoc(0, y, x, y);
+ std::cout << y << std::endl;
+ tracker->setTracked (true, y, 0);
+ m.waitOk ();
+ }
+ else
+ {
+ tracker->setTracked (false, 1, 1);
+ m.waitOk ();
+ }
+ std::cout << "-------------\n" << std::endl;
+
+ i++;
+ }
+ /////////////////////////////////////////////////////////////////////////////////////////
+ return 0;
+ }
+ catch (const std::exception &e)
+ {
+ std::cout << e.what () << std::endl;
+ return 1;
+ }
+}
+