summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/ui/liveView.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/ui/liveView.cc')
-rw-r--r--2005/i/robert/src/ovision/ui/liveView.cc67
1 files changed, 60 insertions, 7 deletions
diff --git a/2005/i/robert/src/ovision/ui/liveView.cc b/2005/i/robert/src/ovision/ui/liveView.cc
index f80dc7b..f85916c 100644
--- a/2005/i/robert/src/ovision/ui/liveView.cc
+++ b/2005/i/robert/src/ovision/ui/liveView.cc
@@ -6,6 +6,8 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
+#include <vector>
+#include <string>
#include "adjust.hh"
#include "live.hh"
@@ -20,6 +22,10 @@ int window;
Live *live;
int width=538; int height=395;
static const unsigned nbImg = 4;
+std::vector<std::string> *fileList;
+Live::ImageInput ii;
+unsigned iFileList;
+unsigned nnNbColor;
/// Chargement d'une texture a partir de donnees RGB
unsigned int
@@ -133,13 +139,27 @@ keyPressed(unsigned char key, int x, int y)
glutDestroyWindow(window);
exit (0);
}
- if (key == ' ')
+ else if (key == ' ')
{
- live->updateImg ("shots/quille1.rgb");
- drawGLScene ();
+ if (iFileList < (fileList->size ()-1))
+ {
+ ++iFileList;
+ live->updateImg ((*fileList)[iFileList].c_str ());
+ }
}
- if (key == 'r')
+ else if (key == 'r')
live->reloadConfig ("rc/vision.conf");
+ else if (key == 'm')
+ std::cout << "Nombre de couleurs du prochain réseau de neurones : " << ++nnNbColor << std::endl;
+ else if (key == 'l')
+ std::cout << "Nombre de couleurs du prochain réseau de neurones : " << ++nnNbColor << std::endl;
+ else if (key == 13)
+ {
+ live->segm->buildNN (nnNbColor, Segm::generate);
+ live->segm->trainNN (live->img);
+ live->updateImg ((*fileList)[iFileList].c_str ());
+ }
+ drawGLScene ();
}
/// Gestion souris
@@ -148,27 +168,60 @@ mouseFunc(int button, int state, int x, int y)
{
}
+/// Analyse la ligne de commande
+void
+parseCommandLine (int argc, char **argv, Live::ImageInput &ii, std::vector<std::string> &list)
+{
+ if (argc < 2)
+ {
+ std::cerr << "Usage : ./liveView {file, cam, socket} [liste d'images]" << std::endl;
+ exit (1);
+ }
+ std::string str (argv[1]);
+ if (str == "file") ii = Live::file;
+ else if (str == "cam") ii = Live::cam;
+ else if (str == "socket") ii = Live::socket;
+ if ((argc < 3) && (ii == Live::file))
+ {
+ std::cerr << "Usage : ./liveView {file, cam, socket} [liste d'images]" << std::endl;
+ exit (1);
+ }
+ while (--argc > 0)
+ {
+ std::string *str = new std::string (argv[argc]);
+ list.push_back (*str);
+ std::cout << *str << std::endl;
+ }
+}
+
/// Fonction principale
int
main(int argc, char **argv)
{
+ fileList = new std::vector<std::string>;
+ parseCommandLine (argc, argv, ii, *fileList);
// Initialisation de l'OpenGL
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(width, height);
glutInitWindowPosition(0, 0);
- window = glutCreateWindow("liveCam - APBteam");
+ window = glutCreateWindow("liveView - APBteam");
glutDisplayFunc(&drawGLScene);
glutReshapeFunc(&reSizeGLScene);
glutKeyboardFunc(&keyPressed);
glutMouseFunc(&mouseFunc);
initGL(WIDTH, HEIGHT);
- live = new Live (nbImg);
- live->init ("shots/test.rgb");
+ iFileList = 0;
+ nnNbColor = 6;
+
+ live = new Live (nbImg, ii);
+ live->init ((*fileList)[0].c_str ());
// Boucle principale
glutMainLoop();
+ delete live;
+ delete fileList;
return 1;
}