00001
00002
00003 #ifndef IMAGE_IMAGE_READER_HPP
00004 #define IMAGE_IMAGE_READER_HPP
00005
00006 #include <string>
00007
00008 #include "kernel/jafarMacro.hpp"
00009 #include "kernel/keyValueFile.hpp"
00010 #include "image/cImage.h"
00011
00012 namespace jafar {
00013 namespace image {
00014 class Image;
00015 class ImagePreprocessor;
00016 }
00017 namespace datareader {
00018
00019 enum BayerType {
00020 bayerNo = 0,
00021 bayerBG = JfrImage_CS_BayerBG,
00022 bayerGB = JfrImage_CS_BayerGB,
00023 bayerRG = JfrImage_CS_BayerRG,
00024 bayerGR = JfrImage_CS_BayerGR
00025 };
00026
00031 class ImageReader {
00032
00033 private:
00034 std::string directory;
00035 std::string pattern;
00036 int width;
00037 int height;
00038 int depth;
00039 double reduction;
00040 int first;
00041 int last;
00042 int step;
00043 BayerType isBayerized;
00044 bool isRectified;
00045 double scale;
00046
00047 jafar::image::ImagePreprocessor* m_imagePreprocessor;
00048 public:
00049
00050 ImageReader() : scale(1.0), m_imagePreprocessor(0) {}
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 void setup(std::string directory_,
00069 std::string pattern_ = "image.%04d.tiff",
00070 double scale_ = 1.0,
00071 BayerType isBayerized_ = bayerNo,
00072 int width_ = -1, int height_ = -1, int depth_ = -1,
00073 int first_ = -1, int last_ = -1, int step_ = 1,
00074 double reduction = 1.0,
00075 bool isRectified_ = false);
00076
00078 std::string getFilePath(unsigned int index) const;
00079
00080 int getImageWidth() const { return width; }
00081 int getImageHeight() const { return height; }
00082 int getImageDepth() const { return depth; }
00083 double getOriginalReduction() const { return reduction; }
00084 int getFirstIndex() const { return first; }
00085 int getLastIndex() const { return last; }
00086 int getIndexStep() const { return step; }
00087 double getScale() const { return scale; }
00088 bool isImageBayerized() const { return isBayerized; }
00089 bool isImageRectified() const { return isRectified; }
00090
00096 void loadImage(unsigned int index_, image::Image& image) const;
00097
00102 jafar::image::Image* loadImage(unsigned int index_) const;
00103
00104 inline void setImagePreprocessor(jafar::image::ImagePreprocessor* imagePreprocessor)
00105 {
00106 m_imagePreprocessor = imagePreprocessor;
00107 }
00108 };
00109
00115 #ifndef SWIG
00116 class JAFAR_DEPRECATED StereoImageReader {
00117 #else
00118 class StereoImageReader {
00119 #endif
00120
00121 private:
00122 ImageReader m_leftImageReader;
00123 ImageReader m_rightImageReader;
00124
00125 public:
00126 StereoImageReader() {}
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 void setup(std::string directory_,
00150 std::string leftPattern_ = "image.l.%04d.tiff",
00151 std::string rightPattern_ = "image.r.%04d.tiff",
00152 double scale_ = 1.0,
00153 BayerType isBayerized_ = bayerNo,
00154 int width_ = -1, int height_ = -1, int depth_ = -1,
00155 int first_ = -1, int last_ = -1, int step_ = 1,
00156 double reduction = 1.0,
00157 bool isRectified_ = false);
00158
00160 jafar::image::Image* loadLeft(unsigned int index_) const;
00162 jafar::image::Image* loadRight(unsigned int index_) const;
00163
00164 };
00165 }
00166 }
00167 #endif // IMAGE_IMAGE_READER_HPP