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.cc101
1 files changed, 67 insertions, 34 deletions
diff --git a/2005/i/robert/src/ovision/ui/liveView.cc b/2005/i/robert/src/ovision/ui/liveView.cc
index 6aef4e1..39b7832 100644
--- a/2005/i/robert/src/ovision/ui/liveView.cc
+++ b/2005/i/robert/src/ovision/ui/liveView.cc
@@ -8,6 +8,7 @@
#include <signal.h>
#include <vector>
#include <string>
+#include <sstream>
#include "adjust.hh"
#include "live.hh"
@@ -28,6 +29,7 @@ unsigned iFileList;
unsigned nnNbColor;
Image::PixelFormat pf;
int colorToFind;
+int numSavedImg;
/// Chargement d'une texture a partir de donnees RGB
unsigned int
@@ -141,56 +143,83 @@ keyPressed(unsigned char key, int x, int y)
glutDestroyWindow(window);
exit (0);
}
- else if (key == ' ')
+ if (ii == Live::file)
{
- if (iFileList < (fileList->size ()-1))
+ if (key == ' ')
{
- ++iFileList;
- live->updateImg ((*fileList)[iFileList].c_str (), pf);
+ if (iFileList < (fileList->size ()-1))
+ {
+ ++iFileList;
+ live->updateImg (pf, (*fileList)[iFileList].c_str ());
+ }
}
- }
- else if (key == 8)
- {
- if (iFileList > 0)
+ else if (key == 8)
{
- --iFileList;
- live->updateImg ((*fileList)[iFileList].c_str (), pf);
+ if (iFileList > 0)
+ {
+ --iFileList;
+ live->updateImg (pf, (*fileList)[iFileList].c_str ());
+ }
}
- }
- else if (key == 'b')
- {
- if (colorToFind > -1)
+ else if (key == 'b')
+ {
+ if (colorToFind > -1)
+ {
+ --colorToFind;
+ live->setColorToFind (colorToFind);
+ live->updateImg (pf, (*fileList)[iFileList].c_str ());
+ std::cout << "Couleur sélectionnée " << colorToFind << std::endl;
+ }
+ }
+ else if (key == 'n')
{
- --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;
+ if (live->oconfig->nnNbColor > colorToFind)
+ {
+ ++colorToFind;
+ live->setColorToFind (colorToFind);
+ live->updateImg (pf, (*fileList)[iFileList].c_str ());
+ std::cout << "Couleur sélectionnée " << colorToFind << std::endl;
+ }
+ }
+ else if (key == 13)
+ {
+ {
+ live->segm->setMode (pf);
+ live->segm->buildNN (nnNbColor, Segm::generate);
+ live->segm->trainNN (live->img);
+ live->updateImg (pf, (*fileList)[iFileList].c_str ());
+ }
}
}
- else if (key == 'n')
+ else if (ii == Live::cam)
{
- if (live->oconfig->nnNbColor > colorToFind)
+ if (key == ' ')
+ live->updateImg ();
+ else if (key == 13)
+ {
+ live->segm->setMode (pf);
+ live->segm->buildNN (nnNbColor, Segm::generate);
+ live->segm->trainNN (live->img);
+ live->updateImg (pf);
+ }
+ else if (key == 's')
{
- ++colorToFind;
- live->setColorToFind (colorToFind);
- live->updateImg ((*fileList)[iFileList].c_str ());
- std::cout << "Couleur sélectionnée " << colorToFind << std::endl;
+ std::string f;
+ std::ostringstream n;
+ n << numSavedImg++;
+ f = "cam" + n.str ();
+ if (pf == Image::rgb) f += ".rgb";
+ else if (pf == Image::yuv) f+= ".yuv";
+ live->img->writeRaw (f.c_str ());
+ std::cout << "Image sauvée dans " << f << std::endl;
}
}
- else if (key == 'r')
+ 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->setMode (pf);
- live->segm->buildNN (nnNbColor, Segm::generate);
- live->segm->trainNN (live->img);
- live->updateImg ((*fileList)[iFileList].c_str ());
- }
drawGLScene ();
}
@@ -255,9 +284,13 @@ main(int argc, char **argv)
iFileList = 0;
nnNbColor = 6;
colorToFind = -1;
+ numSavedImg = 0;
live = new Live (nbImg, ii);
- live->init ((*fileList)[0].c_str (), pf);
+ if (ii == Live::file)
+ live->init (pf, (*fileList)[0].c_str ());
+ else
+ live->init (pf);
// Boucle principale
glutMainLoop();