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/Makefile.defs4
-rw-r--r--2005/i/robert/src/ovision/ui/comm.cc11
-rw-r--r--2005/i/robert/src/ovision/ui/live.cc36
-rw-r--r--2005/i/robert/src/ovision/ui/live.hh7
-rw-r--r--2005/i/robert/src/ovision/ui/liveView.cc2
5 files changed, 49 insertions, 11 deletions
diff --git a/2005/i/robert/src/ovision/ui/Makefile.defs b/2005/i/robert/src/ovision/ui/Makefile.defs
index 343e45f..b212205 100644
--- a/2005/i/robert/src/ovision/ui/Makefile.defs
+++ b/2005/i/robert/src/ovision/ui/Makefile.defs
@@ -2,8 +2,8 @@ PROGRAMS += adjust ui liveView
LIBSGL= -L/usr/X11R6/lib -lGL -lGLU -lglut
LIBNCURSES=-lmenu -lncurses
-adjust_OBJECTS = adjust.o comm.o live.o $(ovision_OBJECTS) $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS)
-liveView_OBJECTS = liveView.o live.o $(ovision_OBJECTS) $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS)
+adjust_OBJECTS = adjust.o comm.o live.o $(ovision_OBJECTS) $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS) $(net_OBJECTS)
+liveView_OBJECTS = liveView.o live.o $(ovision_OBJECTS) $(data_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(utils_OBJECTS) $(net_OBJECTS)
ui_OBJECTS = ui.o mainui.o oconfig.o group.o segm.o
ui: $(ui_OBJECTS:%.o=%.o)
diff --git a/2005/i/robert/src/ovision/ui/comm.cc b/2005/i/robert/src/ovision/ui/comm.cc
index a2109c4..0065bd2 100644
--- a/2005/i/robert/src/ovision/ui/comm.cc
+++ b/2005/i/robert/src/ovision/ui/comm.cc
@@ -107,6 +107,7 @@ Comm::executeUiCmds (const char *buffer)
}
// On live_->segmente l'image puis on la stocke
live_->segmAndGroup ();
+ live_->rootPics ();
std::cout << "Couleur " << numColor << " changé aux valeurs " << (int)live_->segm->node_[numColor*3] << " " << (int)live_->segm->node_[numColor*3+1] << " " << (int)live_->segm->node_[numColor*3+2];
break;
@@ -136,6 +137,7 @@ Comm::executeUiCmds (const char *buffer)
}
// On live_->segmente l'image puis on la stocke
live_->segmAndGroup();
+ live_->rootPics ();
std::cout << nbColorToMerge << " colors merged to " << numIndexColor << std::endl;
}
break;
@@ -145,10 +147,16 @@ Comm::executeUiCmds (const char *buffer)
ss >> numColorToShow;
// Cas ou toutes les couleurs doivent etre affiche
if (numColorToShow == -1)
+ {
live_->segmAndGroup ();
+ live_->rootPics ();
+ }
// Afficher seulement une couleur
else
+ {
live_->segmAndGroup (numColorToShow);
+ live_->rootPics ();
+ }
break;
case 'd': // supprimer couleur
@@ -168,6 +176,8 @@ Comm::executeUiCmds (const char *buffer)
live_->segm->showNodes();
// On live_->segmente l'image puis on la stocke
live_->segmAndGroup();
+ live_->rootPics ();
+
break;
case 'r': // Reload l'image
@@ -269,6 +279,7 @@ Comm::executeUiCmds (const char *buffer)
live_->segm->trainNN(live_->img);
// On live_->segmente l'image puis on la stocke
live_->segmAndGroup();
+ live_->rootPics ();
// Synchronisation des poids avec ui
sendNodes();
break;
diff --git a/2005/i/robert/src/ovision/ui/live.cc b/2005/i/robert/src/ovision/ui/live.cc
index 60918ac..2484f32 100644
--- a/2005/i/robert/src/ovision/ui/live.cc
+++ b/2005/i/robert/src/ovision/ui/live.cc
@@ -16,12 +16,14 @@
#include "image/raw_reader.hh"
#include "data/data_input_file.hh"
#include "video4linux/video4linux.hh"
+#include "socket/server_socket.hh"
+#include "socket/address.hh"
/// Constructeur
/// @param *filename nom de l'image a utiliser
Live::Live (const unsigned nbImg, const ImageInput imgInput)
- : colorToFind_ (-1), group (0), width_ (640), height_ (480),
- imgInput_ (imgInput)
+ : reader_ (0), db_ (0), st_ (0), colorToFind_ (-1), group (0),
+ width_ (640), height_ (480), imgInput_ (imgInput)
{
if (nbImg < 6) nbImg_ = 6;
else nbImg_ = nbImg;
@@ -62,6 +64,21 @@ Live::init (const Image::PixelFormat pf, const char *filename)
}
break;
case socket:
+ {
+ // Serveur
+ ServerSocket ss (2000);
+ Address a;
+ SocketText *st_ = new SocketText (ss, a);
+ st_->nonblock ();
+ // DataBuffer de reception
+ DataBuffer *db_ = new DataBuffer;
+ // Reception des données
+ while (!st_->recv ());
+ *st_ >> *db_;
+ if (db_->type () != DataBuffer::Image)
+ std::cerr << "<Live::init> Echec de la transmission\n";
+ reader_ = new RawReader (*db_, width_, height_, pf);
+ }
break;
}
img->load (*reader_);
@@ -74,7 +91,9 @@ Live::init (const Image::PixelFormat pf, const char *filename)
segm = new SegmLearn;
segm->setMode (pf);
segm->buildNN (oconfig->nnNbColor, Segm::loadFromFile);
- mag = new Magnifier (img, segm, Group::ZoneType (oconfig->uiGroupToDisplay));
+ eraser = new Eraser (oconfig->width, 10);
+ eraser->init ();
+ mag = new Magnifier (img, segm, eraser, Group::ZoneType (oconfig->uiGroupToDisplay));
segmAndGroup ();
// Affichage de l'image pilote avec la couleur d'aquisition et en RGB
tex[1] = loadImage (img->width_, img->height_, data[0], tex[1]);
@@ -101,9 +120,7 @@ Live::updateImg (const Image::PixelFormat pf, const char *filename)
}
break;
case cam:
- {
std::cout << "<Live::updateImg> Changement d'image caméra" << std::endl;
- }
case socket:
break;
}
@@ -133,6 +150,9 @@ Live::~Live()
delete segm;
delete group;
delete [] data;
+ delete db_;
+ delete st_;
+ delete reader_;
}
/// Recharge le fichier de config
@@ -150,7 +170,7 @@ Live::segmAndGroup (const int numColorToShow)
// Création des groupes
delete group;
- group = new Group (img, segm);
+ group = new Group (img, segm, eraser);
std::vector<Zone> list;
if (numColorToShow >= 0)
{
@@ -179,6 +199,6 @@ Live::segmAndGroup (const int numColorToShow)
// Création de l'image segmentée
img->doImg ();
memcpy (data[2], img->getTabOut (), sizeof (char)*img->nbPixels_*3);
- tex[2] = loadImage(img->width_, img->height_, data[2], tex[2]);
- tex[5] = loadImage(img->width_, img->height_, data[5], tex[5]);
+// tex[2] = loadImage(img->width_, img->height_, data[2], tex[2]);
+// tex[5] = loadImage(img->width_, img->height_, data[5], tex[5]);
}
diff --git a/2005/i/robert/src/ovision/ui/live.hh b/2005/i/robert/src/ovision/ui/live.hh
index 4eac3be..c9137a8 100644
--- a/2005/i/robert/src/ovision/ui/live.hh
+++ b/2005/i/robert/src/ovision/ui/live.hh
@@ -30,6 +30,9 @@
#include "ovision/see/oconfig.hh"
#include "ovision/see/group.hh"
#include "ovision/see/magnifier.hh"
+
+#include "socket/socket_text.hh"
+#include "data/data_buffer.hh"
#define NB_POINTS_UI 6
@@ -38,6 +41,8 @@ class Live
{
unsigned nbImg_;
ImageReader *reader_;
+ DataBuffer *db_;
+ SocketText *st_;
int colorToFind_;
public:
enum ImageInput {file, cam, socket};
@@ -56,6 +61,8 @@ class Live
OConfig *oconfig;
/// classe segmentation
SegmLearn *segm;
+ /// classe eraser
+ Eraser *eraser;
/// classe group
Group *group;
/// classe magnifier
diff --git a/2005/i/robert/src/ovision/ui/liveView.cc b/2005/i/robert/src/ovision/ui/liveView.cc
index 0357456..e903f26 100644
--- a/2005/i/robert/src/ovision/ui/liveView.cc
+++ b/2005/i/robert/src/ovision/ui/liveView.cc
@@ -187,7 +187,7 @@ keyPressed(unsigned char key, int x, int y)
}
}
}
- else if (ii == Live::cam)
+ else if ((ii == Live::cam) || (ii == Live::socket))
{
if (key == ' ')
live->updateImg ();