From 0432e1772412d42036124a213663105eb52fb02a Mon Sep 17 00:00:00 2001 From: gaillaro Date: Wed, 6 Apr 2005 17:30:14 +0000 Subject: - suppression de const sur getParm - ajout d'une option facultative de luminosité sur la ligne de commande pour test_video4linux - qq modifs sur liveView --- 2005/i/robert/src/image/image_reader.hh | 2 +- 2005/i/robert/src/image/raw_reader.cc | 2 +- 2005/i/robert/src/image/raw_reader.hh | 2 +- 2005/i/robert/src/ovision/ui/Makefile.defs | 2 +- 2005/i/robert/src/ovision/ui/live.cc | 6 +- 2005/i/robert/src/ovision/ui/live.hh | 4 +- 2005/i/robert/src/ovision/ui/liveView.cc | 67 ++++++++++++++++++++--- 2005/i/robert/src/video4linux/test_video4linux.cc | 12 +++- 2005/i/robert/src/video4linux/video4linux.hh | 2 +- 9 files changed, 79 insertions(+), 20 deletions(-) (limited to '2005/i') diff --git a/2005/i/robert/src/image/image_reader.hh b/2005/i/robert/src/image/image_reader.hh index fd6d308..81020bd 100644 --- a/2005/i/robert/src/image/image_reader.hh +++ b/2005/i/robert/src/image/image_reader.hh @@ -34,7 +34,7 @@ class ImageReader virtual ~ImageReader (void) { } /// Récupère les paramètres de l'image. virtual void getParam (int &width, int &height, - Image::PixelFormat &pixelFormat) const = 0; + Image::PixelFormat &pixelFormat) = 0; /// Lit une image, lance une exception en cas d'erreur. virtual void read (uint8_t *buf, unsigned size) = 0; }; diff --git a/2005/i/robert/src/image/raw_reader.cc b/2005/i/robert/src/image/raw_reader.cc index e77df08..f3e87b6 100644 --- a/2005/i/robert/src/image/raw_reader.cc +++ b/2005/i/robert/src/image/raw_reader.cc @@ -38,7 +38,7 @@ RawReader::RawReader (DataInput &data, int width, int height, /// Récupère les paramètres de l'image. void RawReader::getParam (int &width, int &height, - Image::PixelFormat &pixelFormat) const + Image::PixelFormat &pixelFormat) { width = width_; height = height_; diff --git a/2005/i/robert/src/image/raw_reader.hh b/2005/i/robert/src/image/raw_reader.hh index e62452d..b5ecd78 100644 --- a/2005/i/robert/src/image/raw_reader.hh +++ b/2005/i/robert/src/image/raw_reader.hh @@ -41,7 +41,7 @@ class RawReader : public ImageReader Image::PixelFormat pixelFormat); /// Récupère les paramètres de l'image. void getParam (int &width, int &height, - Image::PixelFormat &pixelFormat) const; + Image::PixelFormat &pixelFormat); /// Lit une image, lance une exception en cas d'erreur. void read (uint8_t *buf, unsigned size); }; diff --git a/2005/i/robert/src/ovision/ui/Makefile.defs b/2005/i/robert/src/ovision/ui/Makefile.defs index 3bddbf3..8657716 100644 --- a/2005/i/robert/src/ovision/ui/Makefile.defs +++ b/2005/i/robert/src/ovision/ui/Makefile.defs @@ -1,4 +1,4 @@ -PROGRAMS += adjust ui +PROGRAMS += adjust ui liveView LIBS += adjust.a LIBSGL= -L/usr/X11R6/lib -lGL -lGLU -lglut LIBNCURSES=-lmenu -lncurses diff --git a/2005/i/robert/src/ovision/ui/live.cc b/2005/i/robert/src/ovision/ui/live.cc index 21a7c3e..5bc87ac 100644 --- a/2005/i/robert/src/ovision/ui/live.cc +++ b/2005/i/robert/src/ovision/ui/live.cc @@ -57,7 +57,7 @@ Live::init (const char *filename) reader_ = reinterpret_cast (r); } break; - case serv: + case socket: break; } img->load (*reader_); @@ -102,7 +102,7 @@ Live::updateImg (const char *filename) } break; case cam: - case serv: + case socket: break; } img->load (*reader_); @@ -143,7 +143,7 @@ Live::reloadConfig (const char *filename) /// Segmente et group les couleurs void -Live::segmAndGroup(int numColorToShow) +Live::segmAndGroup (const int numColorToShow) { // Création des groupes delete group; diff --git a/2005/i/robert/src/ovision/ui/live.hh b/2005/i/robert/src/ovision/ui/live.hh index 7c5301e..9b8936b 100644 --- a/2005/i/robert/src/ovision/ui/live.hh +++ b/2005/i/robert/src/ovision/ui/live.hh @@ -39,7 +39,7 @@ class Live unsigned nbImg_; ImageReader *reader_; public: - enum ImageInput {file, cam, serv}; + enum ImageInput {file, cam, socket}; /// Constructeur Live (const unsigned nbImg, const ImageInput imgInput = file); /// Destructeur @@ -67,7 +67,7 @@ class Live /// Recharge le fichier de config void reloadConfig (const char *filename); /// Segmentation et groupement des couleurs - void segmAndGroup(int numColorToShow = -1); + void segmAndGroup (const int numColorToShow = -1); /// Fixe une image ségmentée et une image de groupe dans la partie centrale void rootPics (); /// Mis à jour de l'image 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 #include #include +#include +#include #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 *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 &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; + 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; } diff --git a/2005/i/robert/src/video4linux/test_video4linux.cc b/2005/i/robert/src/video4linux/test_video4linux.cc index 9abdf4a..6373407 100644 --- a/2005/i/robert/src/video4linux/test_video4linux.cc +++ b/2005/i/robert/src/video4linux/test_video4linux.cc @@ -38,9 +38,9 @@ main (int argc, char **argv) { try { - if (argc != 3) + if ((argc != 3) && (argc != 4)) throw std::runtime_error ("Syntaxe : fichier " - "{rgb|bgr|yuv|yuv422}"); + "{rgb|bgr|yuv|yuv422} [luminosité]"); std::string format (argv[2]); Image::PixelFormat pf; if (format == "rgb") @@ -53,7 +53,13 @@ main (int argc, char **argv) pf = Image::yuv422; else throw std::invalid_argument ("Syntaxe : fichier {rgb|yuv422}"); - Video4Linux vid ("/dev/video", pf); + int lum = 58000; + if (argc == 4) + { + std::istringstream isLum (argv[3]); + isLum >> lum; + } + Video4Linux vid ("/dev/video", pf, lum); vid.calibrate (); int w, h; vid.getParam (w, h, pf); diff --git a/2005/i/robert/src/video4linux/video4linux.hh b/2005/i/robert/src/video4linux/video4linux.hh index 1a38056..bce8fe6 100644 --- a/2005/i/robert/src/video4linux/video4linux.hh +++ b/2005/i/robert/src/video4linux/video4linux.hh @@ -45,7 +45,7 @@ class Video4Linux : public ImageReader ~Video4Linux (void); /// Récupère les paramètres de l'image. void getParam (int &width, int &height, - Image::PixelFormat &pixelFormat) const + Image::PixelFormat &pixelFormat) { width = width_; height = height_; pixelFormat = pixelFormat_; } /// Lit une image, lance une exception en cas d'erreur. void read (uint8_t *buf, unsigned size); -- cgit v1.2.3