fileloader.h

00001
00002 /***************************************************************************
00003  *  fileloader.h - A camera which obtains its images from a single image
00004  *                 file or from several image files in a directory
00005  *
00006  *  Generated: Tue Mar  2 12:26:44 2005
00007  *  Copyright  2005  Tim Niemueller [www.niemueller.de]
00008  *             2008       Daniel Beck
00009  *
00010  ****************************************************************************/
00011
00012 /*  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version. A runtime exception applies to
00016  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU Library General Public License for more details.
00022  *
00023  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00024  */
00025
00026 #ifndef __FIREVISION_CAMS_FILELOADER_H_
00027 #define __FIREVISION_CAMS_FILELOADER_H_
00028 
00029 #include <cams/camera.h>
00030
00031 class CameraArgumentParser;
00032
00033 class FileLoader : public Camera
00034 {
00035 #if defined(__GLIBC__)
00036   friend int file_select(const struct dirent*);
00037 #else
00038   friend int file_select(struct dirent*);
00039 #endif
00040 
00041  public:
00042
00043   FileLoader(const char *filename);
00044   FileLoader(colorspace_t cspace, const char* filename, unsigned int width, unsigned int height);
00045   FileLoader(const CameraArgumentParser *cap);
00046   ~FileLoader();
00047
00048   virtual void             open();
00049   virtual void             start();
00050   virtual void             stop();
00051   virtual void             close();
00052   virtual void             capture();
00053   virtual void             flush();
00054
00055   virtual bool             ready();
00056
00057   virtual void             print_info();
00058
00059   virtual unsigned char *  buffer();
00060   virtual unsigned int     buffer_size();
00061   virtual void             dispose_buffer();
00062
00063   virtual unsigned int     pixel_width();
00064   virtual unsigned int     pixel_height();
00065   virtual colorspace_t     colorspace();
00066
00067   virtual void             set_image_number(unsigned int n);
00068
00069   void                     set_colorspace(colorspace_t c);
00070   void                     set_pixel_width(unsigned int w);
00071   void                     set_pixel_height(unsigned int h);
00072
00073  private:
00074   void                     read_file();
00075
00076   bool started;
00077   bool opened;
00078   unsigned char* file_buffer;
00079   int _buffer_size;
00080   unsigned int width;
00081   unsigned int height;
00082   colorspace_t cspace;
00083   char *filename;
00084   char *dirname;
00085   static char *extension;
00086   int num_files;
00087   int cur_file;
00088   struct dirent **file_list;
00089 };
00090
00091 #endif