summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/ui
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/ui')
-rw-r--r--2005/i/robert/src/ovision/ui/comm.cc44
-rw-r--r--2005/i/robert/src/ovision/ui/live.cc11
-rw-r--r--2005/i/robert/src/ovision/ui/live.hh4
-rw-r--r--2005/i/robert/src/ovision/ui/liveView.cc101
4 files changed, 99 insertions, 61 deletions
diff --git a/2005/i/robert/src/ovision/ui/comm.cc b/2005/i/robert/src/ovision/ui/comm.cc
index beb4be8..0d692a2 100644
--- a/2005/i/robert/src/ovision/ui/comm.cc
+++ b/2005/i/robert/src/ovision/ui/comm.cc
@@ -38,7 +38,7 @@ Comm::init ()
fclose(file);
live_ = new Live (NBIMG);
- live_->init (fname);
+ live_->init (Image::rgb, fname);
}
/// Destructeur
@@ -111,31 +111,33 @@ Comm::executeUiCmds (const char *buffer)
break;
case 'm': // mélanger couleurs
- int nbColorToMerge, numIndexColor;
-
- // Si on recoit une commande de remise a zero de l'index_
- ss >> nbColorToMerge;
- if (nbColorToMerge == -1)
- {
- for (int i=0; i<live_->oconfig->nnNbColor; i++)
- live_->segm->index_[i] = i;
- }
- // Sinon on mix les couleurs
- else
{
- numIndexColor = live_->segm->index_[nbColorToMerge];
+ int nbColorToMerge, numIndexColor = 0;
- // On inscrit les changements dans l'index_
- int numColorToMerge;
- for (int i=1; i<nbColorToMerge; i++)
+ // Si on recoit une commande de remise a zero de l'index_
+ ss >> nbColorToMerge;
+ if (nbColorToMerge == -1)
{
- ss >> numColorToMerge;
- live_->segm->index_[numColorToMerge] = numIndexColor;
+ for (int i=0; i<live_->oconfig->nnNbColor; i++)
+ live_->segm->index_[i] = i;
}
+ // Sinon on mix les couleurs
+ else
+ {
+ numIndexColor = live_->segm->index_[nbColorToMerge];
+
+ // On inscrit les changements dans l'index_
+ int numColorToMerge;
+ for (int i=1; i<nbColorToMerge; i++)
+ {
+ ss >> numColorToMerge;
+ live_->segm->index_[numColorToMerge] = numIndexColor;
+ }
+ }
+ // On live_->segmente l'image puis on la stocke
+ live_->segmAndGroup();
+ std::cout << nbColorToMerge << " colors merged to " << numIndexColor << std::endl;
}
- // On live_->segmente l'image puis on la stocke
- live_->segmAndGroup();
- std::cout << nbColorToMerge << " colors merged to " << numIndexColor << std::endl;
break;
case 's': // isole une couleur
diff --git a/2005/i/robert/src/ovision/ui/live.cc b/2005/i/robert/src/ovision/ui/live.cc
index caa4e1b..c7b8b09 100644
--- a/2005/i/robert/src/ovision/ui/live.cc
+++ b/2005/i/robert/src/ovision/ui/live.cc
@@ -29,7 +29,7 @@ Live::Live (const unsigned nbImg, const ImageInput imgInput)
/// Initialisation
void
-Live::init (const char *filename, const Image::PixelFormat pf,
+Live::init (const Image::PixelFormat pf, const char *filename,
const unsigned width, const unsigned height)
{
tex = new unsigned[nbImg_];
@@ -88,7 +88,7 @@ Live::init (const char *filename, const Image::PixelFormat pf,
/// Mis à jour de l'image
void
-Live::updateImg (const char *filename, const Image::PixelFormat pf,
+Live::updateImg (const Image::PixelFormat pf, const char *filename,
const unsigned width, const unsigned height)
{
segm->setMode (pf);
@@ -107,6 +107,9 @@ Live::updateImg (const char *filename, const Image::PixelFormat pf,
}
break;
case cam:
+ {
+ std::cout << "<Live::updateImg> Changement d'image caméra" << std::endl;
+ }
case socket:
break;
}
@@ -153,7 +156,7 @@ Live::segmAndGroup (const int numColorToShow)
std::cout << numColorToShow << std::endl;
// Création des groupes
delete group;
- group = new Group(img, segm);
+ group = new Group (img, segm);
std::vector<Zone> list;
if (numColorToShow >= 0)
{
@@ -162,7 +165,7 @@ Live::segmAndGroup (const int numColorToShow)
}
else
{
- group->jumpPoints(oconfig->groupColor);
+ group->jumpPoints (oconfig->groupColor);
mag->analyse (group->getZoneList ());
list = mag->getItemList ((Group::ZoneType)oconfig->uiGroupToDisplay);
}
diff --git a/2005/i/robert/src/ovision/ui/live.hh b/2005/i/robert/src/ovision/ui/live.hh
index 1f9ad7c..7023428 100644
--- a/2005/i/robert/src/ovision/ui/live.hh
+++ b/2005/i/robert/src/ovision/ui/live.hh
@@ -64,7 +64,7 @@ class Live
char fname[100];
/// Initialisation
- void init (const char *filename, const Image::PixelFormat pf = Image::rgb,
+ void init (const Image::PixelFormat pf = Image::rgb, const char *filename = 0,
const unsigned width=360, const unsigned height=296);
/// Recharge le fichier de config
void reloadConfig (const char *filename);
@@ -73,7 +73,7 @@ class Live
/// Fixe une image ségmentée et une image de groupe dans la partie centrale
void rootPics ();
/// Mis à jour de l'image
- void updateImg (const char *filename, const Image::PixelFormat pf = Image::rgb,
+ void updateImg (const Image::PixelFormat pf = Image::rgb, const char *filename = 0,
const unsigned width=360, const unsigned height=296);
/// Accessors
void setColorToFind (const int color) {colorToFind_ = color;}
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();