Fawkes API  Fawkes Development Version
fileloader.h
1 
2 /***************************************************************************
3  * fileloader.h - A camera which obtains its images from a single image
4  * file or from several image files in a directory
5  *
6  * Generated: Tue Mar 2 12:26:44 2005
7  * Copyright 2005 Tim Niemueller [www.niemueller.de]
8  * 2008 Daniel Beck
9  *
10  ****************************************************************************/
11 
12 /* This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version. A runtime exception applies to
16  * this software (see LICENSE.GPL_WRE file mentioned below for details).
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Library General Public License for more details.
22  *
23  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
24  */
25 
26 #ifndef __FIREVISION_CAMS_FILELOADER_H_
27 #define __FIREVISION_CAMS_FILELOADER_H_
28 
29 #include <fvcams/camera.h>
30 #include <dirent.h>
31 
32 namespace firevision {
33 #if 0 /* just to make Emacs auto-indent happy */
34 }
35 #endif
36 
37 class CameraArgumentParser;
38 
39 class FileLoader : public Camera
40 {
41 #if defined(__GLIBC__) || defined(__FreeBSD__)
42  friend int file_select(const struct dirent*);
43 #else
44  friend int file_select(struct dirent*);
45 #endif
46 
47  public:
48 
49  FileLoader(const char *filename);
50  FileLoader(colorspace_t cspace, const char* filename, unsigned int width, unsigned int height);
51  FileLoader(const CameraArgumentParser *cap);
52  ~FileLoader();
53 
54  virtual void open();
55  virtual void start();
56  virtual void stop();
57  virtual void close();
58  virtual void capture();
59  virtual void flush();
60 
61  virtual bool ready();
62 
63  virtual void print_info();
64 
65  virtual unsigned char * buffer();
66  virtual unsigned int buffer_size();
67  virtual void dispose_buffer();
68 
69  virtual unsigned int pixel_width();
70  virtual unsigned int pixel_height();
71  virtual colorspace_t colorspace();
72 
73  virtual void set_image_number(unsigned int n);
74 
75  void set_colorspace(colorspace_t c);
76  void set_pixel_width(unsigned int w);
77  void set_pixel_height(unsigned int h);
78 
79  private:
80  void read_file();
81 
82  bool started;
83  bool opened;
84  unsigned char* file_buffer;
85  int _buffer_size;
86  unsigned int width;
87  unsigned int height;
88  colorspace_t cspace;
89  char *filename;
90  char *dirname;
91  static char *extension;
92  int num_files;
93  int cur_file;
94  struct dirent **file_list;
95 };
96 
97 } // end namespace firevision
98 
99 #endif
FileLoader(const char *filename)
Constructor.
Definition: fileloader.cpp:88
virtual colorspace_t colorspace()
Colorspace of returned image.
Definition: fileloader.cpp:319
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:35
virtual void capture()
Capture an image.
Definition: fileloader.cpp:238
virtual void flush()
Flush image queue.
Definition: fileloader.cpp:286
Camera argument parser.
Definition: camargp.h:38
virtual void stop()
Stop image transfer from the camera.
Definition: fileloader.cpp:225
virtual unsigned int pixel_height()
Height of image in pixels.
Definition: fileloader.cpp:312
virtual void dispose_buffer()
Dispose current buffer.
Definition: fileloader.cpp:280
virtual unsigned int buffer_size()
Size of buffer.
Definition: fileloader.cpp:262
virtual void open()
Open the camera.
Definition: fileloader.cpp:195
void set_colorspace(colorspace_t c)
Set the colorspace of the image.
Definition: fileloader.cpp:329
virtual void print_info()
Print out camera information.
Definition: fileloader.cpp:232
virtual unsigned char * buffer()
Get access to current image buffer.
Definition: fileloader.cpp:255
virtual bool ready()
Camera is ready for taking pictures.
Definition: fileloader.cpp:292
virtual unsigned int pixel_width()
Width of image in pixels.
Definition: fileloader.cpp:305
~FileLoader()
Destructor.
Definition: fileloader.cpp:182
void set_pixel_width(unsigned int w)
Set width.
Definition: fileloader.cpp:339
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
Definition: fileloader.cpp:299
void set_pixel_height(unsigned int h)
Set height.
Definition: fileloader.cpp:349
virtual void start()
Start image transfer from the camera.
Definition: fileloader.cpp:213
virtual void close()
Close camera.
Definition: fileloader.cpp:269
Load images from files.
Definition: fileloader.h:39