summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/optimCam.cc
diff options
context:
space:
mode:
Diffstat (limited to '2004/i/nono/src/ovision/optimCam.cc')
-rw-r--r--2004/i/nono/src/ovision/optimCam.cc105
1 files changed, 105 insertions, 0 deletions
diff --git a/2004/i/nono/src/ovision/optimCam.cc b/2004/i/nono/src/ovision/optimCam.cc
new file mode 100644
index 0000000..8bf2b9c
--- /dev/null
+++ b/2004/i/nono/src/ovision/optimCam.cc
@@ -0,0 +1,105 @@
+
+#include "video4linux/video4linux.h"
+#include "map.h"
+#include "oconfig.h"
+#include "group.h"
+#include "space.h"
+
+#include "segmTable.h"
+#include "segmLearn.h"
+
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/timeb.h>
+static struct timeval _tstart, _tend;
+static struct timezone tz;
+
+void tstart(void)
+{
+ gettimeofday(&_tstart, &tz);
+}
+void tend(void)
+{
+ gettimeofday(&_tend,&tz);
+}
+
+double tval()
+{
+ double t1, t2;
+ t1 = (double)_tstart.tv_sec + (double)_tstart.tv_usec/(1000*1000);
+ t2 = (double)_tend.tv_sec + (double)_tend.tv_usec/(1000*1000);
+ return t2-t1;
+}
+
+
+
+int
+main()
+{
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /// Initialisation des classes
+ tstart ();
+ OConfig oconfig("rc/vision.conf");
+
+ Img img;
+ Video4Linux::ColorSpace cs;
+ cs = Video4Linux::rgb;
+ Video4Linux v4l("/dev/video", cs, 60000);
+ v4l.calibrate ();
+
+ // Prendre une image pour que la taille de l'image soit configuré
+ img.load (v4l);
+
+ Space space(img.width, img.height);
+ space.AddSetupPoint (356, 23, 300, 300);
+ space.AddSetupPoint (283, 171, 600, 600);
+ space.AddSetupPoint (253, 234, 1000, 900);
+ space.Setup (0.00603759, 0.593767, 291.474);
+
+ SegmTable segmNN(&img);
+ segmNN.BuildNN(oconfig.nn_NbCouleurs, LOAD_FROM_FILE);
+ segmNN.DoColorTable ();
+
+ Group group(&img, &segmNN);
+
+ Map map(&space);
+ tend ();
+ std::cout << "Initialisation:\t" << tval () << std::endl;
+ /////////////////////////////////////////////////////////////////////////////////////////
+
+
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /// Prends une image a partir de la camera et l'analyse
+
+ tstart ();
+ img.load(v4l);
+ tend ();
+ std::cout << "Acquisition img:\t" << tval () << std::endl;
+
+ tstart ();
+ //segmNN.Segm();
+ tend ();
+ std::cout << "Segmentation:\t" << tval () << std::endl;
+
+ tstart ();
+ group.JumpPoints(oconfig.groupColor);
+ tend ();
+ std::cout << "Find Group:\t" << tval () << std::endl;
+
+ group.ShowZones ();
+
+ tstart ();
+ if (group.zoneListBall)
+ {
+ int x,y;
+ x = group.zoneListBall->centerx;
+ y = img.height - group.zoneListBall->centery;
+ space.GetLoc(x, y, x, y);
+ tend ();
+ std::cout << "Map:\t\t" << tval () << std::endl;
+
+ }
+ /////////////////////////////////////////////////////////////////////////////////////////
+}
+