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, 54 insertions, 13 deletions
diff --git a/2005/i/robert/src/ovision/ui/liveView.cc b/2005/i/robert/src/ovision/ui/liveView.cc
index f85916c..6aef4e1 100644
--- a/2005/i/robert/src/ovision/ui/liveView.cc
+++ b/2005/i/robert/src/ovision/ui/liveView.cc
@@ -26,6 +26,8 @@ std::vector<std::string> *fileList;
Live::ImageInput ii;
unsigned iFileList;
unsigned nnNbColor;
+Image::PixelFormat pf;
+int colorToFind;
/// Chargement d'une texture a partir de donnees RGB
unsigned int
@@ -144,7 +146,36 @@ keyPressed(unsigned char key, int x, int y)
if (iFileList < (fileList->size ()-1))
{
++iFileList;
+ live->updateImg ((*fileList)[iFileList].c_str (), pf);
+ }
+ }
+ else if (key == 8)
+ {
+ if (iFileList > 0)
+ {
+ --iFileList;
+ live->updateImg ((*fileList)[iFileList].c_str (), pf);
+ }
+ }
+ else if (key == 'b')
+ {
+ if (colorToFind > -1)
+ {
+ --colorToFind;
+ live->setColorToFind (colorToFind);
+ live->updateImg ((*fileList)[iFileList].c_str ());
+ live->updateImg ((*fileList)[iFileList].c_str ());
+ std::cout << "Couleur sélectionnée " << colorToFind << std::endl;
+ }
+ }
+ else if (key == 'n')
+ {
+ if (live->oconfig->nnNbColor > colorToFind)
+ {
+ ++colorToFind;
+ live->setColorToFind (colorToFind);
live->updateImg ((*fileList)[iFileList].c_str ());
+ std::cout << "Couleur sélectionnée " << colorToFind << std::endl;
}
}
else if (key == 'r')
@@ -152,9 +183,10 @@ keyPressed(unsigned char key, int x, int y)
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;
+ std::cout << "Nombre de couleurs du prochain réseau de neurones : " << --nnNbColor << std::endl;
else if (key == 13)
{
+ live->segm->setMode (pf);
live->segm->buildNN (nnNbColor, Segm::generate);
live->segm->trainNN (live->img);
live->updateImg ((*fileList)[iFileList].c_str ());
@@ -168,25 +200,33 @@ mouseFunc(int button, int state, int x, int y)
{
}
+/// Usage
+void
+usage ()
+{
+ std::cerr << "Usage : ./liveView {file, cam, socket} format_image [liste d'images]" << std::endl;
+ exit (1);
+}
+
+
/// 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);
- }
+ if (argc < 3)
+ usage ();
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)
+ else usage ();
+ if ((argc < 4) && (ii == Live::file))
+ usage ();
+ std::string str2 (argv[2]);
+ if (str2 == "rgb") pf = Image::rgb;
+ else if (str2 == "yuv") pf = Image::yuv;
+ else usage ();
+ while (--argc > 2)
{
std::string *str = new std::string (argv[argc]);
list.push_back (*str);
@@ -214,9 +254,10 @@ main(int argc, char **argv)
iFileList = 0;
nnNbColor = 6;
+ colorToFind = -1;
live = new Live (nbImg, ii);
- live->init ((*fileList)[0].c_str ());
+ live->init ((*fileList)[0].c_str (), pf);
// Boucle principale
glutMainLoop();