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
31#include <dirent.h>
32
33namespace firevision {
34
35class CameraArgumentParser;
36
37class FileLoader : public Camera
38{
39/// @cond DOXYGEN_BUG
40#if defined(__GLIBC__) || defined(__FreeBSD__)
41 friend int file_select(const struct dirent *);
42#else
43 friend int file_select(struct dirent *);
44#endif
45 /// @endcond
46
47public:
48 FileLoader(const char *filename);
49 FileLoader(colorspace_t cspace, const char *filename, unsigned int width, unsigned int height);
52
53 virtual void open();
54 virtual void start();
55 virtual void stop();
56 virtual void close();
57 virtual void capture();
58 virtual void flush();
59
60 virtual bool ready();
61
62 virtual void print_info();
63
64 virtual unsigned char *buffer();
65 virtual unsigned int buffer_size();
66 virtual void dispose_buffer();
67
68 virtual unsigned int pixel_width();
69 virtual unsigned int pixel_height();
70 virtual colorspace_t colorspace();
71
72 virtual void set_image_number(unsigned int n);
73
74 void set_colorspace(colorspace_t c);
75 void set_pixel_width(unsigned int w);
76 void set_pixel_height(unsigned int h);
77
78private:
79 void read_file();
80
81 bool started;
82 bool opened;
83 unsigned char * file_buffer;
84 int _buffer_size;
85 unsigned int width;
86 unsigned int height;
87 colorspace_t cspace;
88 char * filename;
89 char * dirname;
90 static char * extension;
91 int num_files;
92 int cur_file;
93 struct dirent **file_list;
94};
95
96} // end namespace firevision
97
98#endif
Camera argument parser.
Definition: camargp.h:36
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:33
Load images from files.
Definition: fileloader.h:38
virtual void capture()
Capture an image.
Definition: fileloader.cpp:234
virtual void flush()
Flush image queue.
Definition: fileloader.cpp:277
void set_colorspace(colorspace_t c)
Set the colorspace of the image.
Definition: fileloader.cpp:314
virtual void dispose_buffer()
Dispose current buffer.
Definition: fileloader.cpp:272
~FileLoader()
Destructor.
Definition: fileloader.cpp:180
FileLoader(const char *filename)
Constructor.
Definition: fileloader.cpp:88
virtual bool ready()
Camera is ready for taking pictures.
Definition: fileloader.cpp:282
void set_pixel_width(unsigned int w)
Set width.
Definition: fileloader.cpp:323
void set_pixel_height(unsigned int h)
Set height.
Definition: fileloader.cpp:332
virtual colorspace_t colorspace()
Colorspace of returned image.
Definition: fileloader.cpp:305
virtual unsigned int buffer_size()
Size of buffer.
Definition: fileloader.cpp:256
virtual void start()
Start image transfer from the camera.
Definition: fileloader.cpp:210
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
Definition: fileloader.cpp:288
virtual void close()
Close camera.
Definition: fileloader.cpp:262
virtual unsigned char * buffer()
Get access to current image buffer.
Definition: fileloader.cpp:250
virtual void open()
Open the camera.
Definition: fileloader.cpp:192
virtual unsigned int pixel_height()
Height of image in pixels.
Definition: fileloader.cpp:299
virtual unsigned int pixel_width()
Width of image in pixels.
Definition: fileloader.cpp:293
virtual void print_info()
Print out camera information.
Definition: fileloader.cpp:229
virtual void stop()
Stop image transfer from the camera.
Definition: fileloader.cpp:223