From b8eada804c20bbb3a9e56fca62c38a08ee7de531 Mon Sep 17 00:00:00 2001 From: gaillaro Date: Sun, 1 May 2005 11:18:55 +0000 Subject: integration nouvelle cam --- 2005/i/robert/src/ovision/ui/comm.cc | 4 ++-- 2005/i/robert/src/ovision/ui/live.cc | 29 ++++++++++++----------------- 2005/i/robert/src/ovision/ui/live.hh | 9 +++++---- 2005/i/robert/src/ovision/ui/liveView.cc | 17 +++++++---------- 4 files changed, 26 insertions(+), 33 deletions(-) (limited to '2005/i/robert/src/ovision') diff --git a/2005/i/robert/src/ovision/ui/comm.cc b/2005/i/robert/src/ovision/ui/comm.cc index 0d692a2..a2109c4 100644 --- a/2005/i/robert/src/ovision/ui/comm.cc +++ b/2005/i/robert/src/ovision/ui/comm.cc @@ -236,14 +236,14 @@ Comm::executeUiCmds (const char *buffer) // Copie du nom de l'image courante ss >> fname; // Ouverture de l'image pilote et stockage - live_->img->loadRaw(fname, Image::rgb, 360, 296); + live_->img->loadRaw(fname, Image::rgb, live_->oconfig->width , live_->oconfig->height); memcpy(live_->data[0], live_->img->tabData_, sizeof(char)*live_->img->nbPixels_*3); live_->tex[0] = loadImage(live_->img->width_, live_->img->height_, live_->data[0], live_->tex[0]); // Conversion en YUV et stockage ConvertImg convert; convert.RGBtoYUV (*live_->img); // NN live_->oconfigure en RGB ou YUV ? - if (!live_->oconfig->inputColor == Image::rgb) live_->img->loadRaw(fname, Image::rgb, 360, 296); + if (!live_->oconfig->inputColor == Image::rgb) live_->img->loadRaw(fname, Image::rgb, live_->oconfig->width, live_->oconfig->height); live_->segmAndGroup(); // Affichage de l'image pilote live_->rootPics (); diff --git a/2005/i/robert/src/ovision/ui/live.cc b/2005/i/robert/src/ovision/ui/live.cc index 62bd1ad..60918ac 100644 --- a/2005/i/robert/src/ovision/ui/live.cc +++ b/2005/i/robert/src/ovision/ui/live.cc @@ -20,7 +20,8 @@ /// Constructeur /// @param *filename nom de l'image a utiliser Live::Live (const unsigned nbImg, const ImageInput imgInput) - : colorToFind_ (-1), group (0), imgInput_ (imgInput) + : colorToFind_ (-1), group (0), width_ (640), height_ (480), + imgInput_ (imgInput) { if (nbImg < 6) nbImg_ = 6; else nbImg_ = nbImg; @@ -29,13 +30,14 @@ Live::Live (const unsigned nbImg, const ImageInput imgInput) /// Initialisation void -Live::init (const Image::PixelFormat pf, const char *filename, - const unsigned width, const unsigned height) +Live::init (const Image::PixelFormat pf, const char *filename) { tex = new unsigned[nbImg_]; data = new unsigned char*[nbImg_]; // Creation de oconfig oconfig = new OConfig (); + width_ = oconfig->width; + height_ = oconfig->height; // Création de l'image img = new ImgInterface; // Ouverture de l'image pilote et stockage @@ -48,15 +50,14 @@ Live::init (const Image::PixelFormat pf, const char *filename, std::string f (fname); DataInputFile *dif = new DataInputFile (f); DataInput *di = reinterpret_cast (dif); - reader_ = new RawReader (*di, width, height, pf); + reader_ = new RawReader (*di, width_, height_, pf); } break; case cam: { Video4Linux *r; - r = new Video4Linux ("/dev/video", pf, oconfig_->brightness); + r = new Video4Linux ("/dev/video", width_, height_, pf, oconfig->brightness); r->calibrate (); - r->setAdaptive (0); reader_ = reinterpret_cast (r); } break; @@ -77,20 +78,12 @@ Live::init (const Image::PixelFormat pf, const char *filename, 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]); - /*if (img->colorMode_ != Image::rgb) - { - ConvertImg conv; - conv.ConvertToRGB (*img); - tex[3] = loadImage (img->width_, img->height_, data[0], tex[4]); - img->loadRaw (fname, Image::rgb, 360, 296); - }*/ rootPics (); } /// Mis à jour de l'image void -Live::updateImg (const Image::PixelFormat pf, const char *filename, - const unsigned width, const unsigned height) +Live::updateImg (const Image::PixelFormat pf, const char *filename) { segm->setMode (pf); switch (imgInput_) @@ -104,7 +97,7 @@ Live::updateImg (const Image::PixelFormat pf, const char *filename, DataInputFile *dif = new DataInputFile (f); DataInput *di = reinterpret_cast (dif); delete reader_; - reader_ = new RawReader (*di, width, height, pf); + reader_ = new RawReader (*di, width_, height_, pf); } break; case cam: @@ -171,6 +164,7 @@ Live::segmAndGroup (const int numColorToShow) list = mag->getItemList ((Group::ZoneType)oconfig->uiGroupToDisplay); } // Création de l'image des groupes + segm->segmImg (img); img->doGroupImg (list); img->doImg (img->getTabSegm ()); memcpy (data[5], img->getTabOut (), sizeof (char)*img->nbPixels_*3); @@ -182,7 +176,8 @@ Live::segmAndGroup (const int numColorToShow) segm->segmImg (img); img->addGroupToDisplay (img->getTabSegm (), list); } - img->doImg (img->getTabSegm ()); + // 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]); diff --git a/2005/i/robert/src/ovision/ui/live.hh b/2005/i/robert/src/ovision/ui/live.hh index b590364..4eac3be 100644 --- a/2005/i/robert/src/ovision/ui/live.hh +++ b/2005/i/robert/src/ovision/ui/live.hh @@ -62,10 +62,11 @@ class Live Magnifier *mag; /// nom de l'image courante char fname[100]; + /// taille image + unsigned width_, height_; /// Initialisation - void init (const Image::PixelFormat pf = Image::rgb, const char *filename = 0, - const unsigned width=360, const unsigned height=296); + void init (const Image::PixelFormat pf = Image::rgb, const char *filename = 0); /// Recharge le fichier de config void reloadConfig (const char *filename); /// Segmentation et groupement des couleurs @@ -73,10 +74,10 @@ 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 Image::PixelFormat pf = Image::rgb, const char *filename = 0, - const unsigned width=360, const unsigned height=296); + void updateImg (const Image::PixelFormat pf = Image::rgb, const char *filename = 0); /// Accessors void setColorToFind (const int color) {colorToFind_ = color;} + void setSize (unsigned width, unsigned height) {width_ = width; height_ = height;} private: ImageInput imgInput_; diff --git a/2005/i/robert/src/ovision/ui/liveView.cc b/2005/i/robert/src/ovision/ui/liveView.cc index 39b7832..0357456 100644 --- a/2005/i/robert/src/ovision/ui/liveView.cc +++ b/2005/i/robert/src/ovision/ui/liveView.cc @@ -15,13 +15,9 @@ using namespace std; -#define IMG_WIDTH 360 -#define IMG_HEIGHT 296 -#define WIDTH 718 -#define HEIGHT 592 +int width, height; int window; Live *live; -int width=538; int height=395; static const unsigned nbImg = 4; std::vector *fileList; Live::ImageInput ii; @@ -66,7 +62,7 @@ initGL(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Plan de projection en 2D - glOrtho(0.0, WIDTH, 0.0, HEIGHT, -1.0, 1.0); + glOrtho(0.0, width, 0.0, height, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); } @@ -85,7 +81,7 @@ reSizeGLScene(int w, int h) glMatrixMode(GL_PROJECTION); // Remise a zero et mode 2D glLoadIdentity(); - glOrtho(0.0, WIDTH, 0.0, HEIGHT, -1.0, 1.0); + glOrtho(0.0, width, 0.0, height, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); } @@ -102,8 +98,8 @@ drawImage(GLuint texId) // Calcul des coordonnees de l'image wMin = BORDER+(texId%3)*(352+BORDER); wMax = 352+BORDER+(texId%3)*(352+BORDER); - hMin = HEIGHT-288-BORDER-(int)(texId/3)*(288+BORDER); - hMax = HEIGHT-BORDER-(int)(texId/3)*(288+BORDER); + hMin = height-288-BORDER-(int)(texId/3)*(288+BORDER); + hMax = height-BORDER-(int)(texId/3)*(288+BORDER); // Dessine un carre contenant l'image glBegin(GL_QUADS); glNormal3f( 0.0f, 0.0f, 1.0f); @@ -267,6 +263,7 @@ parseCommandLine (int argc, char **argv, Live::ImageInput &ii, std::vector; parseCommandLine (argc, argv, ii, *fileList); // Initialisation de l'OpenGL @@ -279,7 +276,7 @@ main(int argc, char **argv) glutReshapeFunc(&reSizeGLScene); glutKeyboardFunc(&keyPressed); glutMouseFunc(&mouseFunc); - initGL(WIDTH, HEIGHT); + initGL(width, height); iFileList = 0; nnNbColor = 6; -- cgit v1.2.3