summaryrefslogtreecommitdiff
path: root/2004
diff options
context:
space:
mode:
authorschodet2004-05-13 19:36:17 +0000
committerschodet2004-05-13 19:36:17 +0000
commit8d488a1b9ee06d8d3a161362e9945acf82f26ade (patch)
tree9d1781e54ce7af1a2e1af8a2a3a507553bd64207 /2004
parent3709bde8401b2e8e81539a26f2b88cabe20aa94f (diff)
Ajout de test_ovision_tracker
Diffstat (limited to '2004')
-rw-r--r--2004/i/nono/src/ovision/Makefile.defs7
-rw-r--r--2004/i/nono/src/ovision/test_ovision_tracker.cc118
2 files changed, 124 insertions, 1 deletions
diff --git a/2004/i/nono/src/ovision/Makefile.defs b/2004/i/nono/src/ovision/Makefile.defs
index 9604038..d4a5307 100644
--- a/2004/i/nono/src/ovision/Makefile.defs
+++ b/2004/i/nono/src/ovision/Makefile.defs
@@ -1,8 +1,11 @@
-TARGETS += test_ovision testimg testmap optim
+TARGETS += test_ovision testimg testmap optim test_ovision_tracker
LIBS += ovision.a
testimg_SOURCES = testimg.cc ovision.a video4linux.a
test_ovision_SOURCES = test_ovision.cc ovision.a image.a video4linux.a
+test_ovision_tracker_SOURCES = test_ovision_tracker.cc ovision.a image.a \
+ video4linux.a motor.a date.a \
+ serial.a utils.a logger.a config.a erreur.a
testmap_SOURCES = testmap.cc ovision.a image.a video4linux.a
testdist_SOURCES = testdist.cc ovision.a
optim_SOURCES = optim.cc ovision.a image.a
@@ -12,6 +15,8 @@ testimg: $(testimg_SOURCES:%.cc=%.o)
test_ovision: $(test_ovision_SOURCES:%.cc=%.o)
+test_ovision_tracker: $(test_ovision_tracker_SOURCES:%.cc=%.o)
+
testmap: $(testmap_SOURCES:%.cc=%.o)
testdist: $(testdist_SOURCES:%.cc=%.o)
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;
+ }
+}
+