Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ImageReader.hpp
00001 /* $Id$ */
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 /*      // for back compatibility purpose ; not compatible with swig for default parameters, ambiguity
00053       void setup(std::string directory_,
00054         std::string prefix_ = "image.",
00055         std::string suffix_ = ".tiff",
00056         unsigned int indexDigits_ = 4,
00057         double scale_ = 1.0,
00058         bool isBayerized_ = false,
00059         int width_ = -1, int height_ = -1, int depth_ = -1,
00060         int first_ = -1, int last_ = -1, int step_ = 1,
00061         double reduction = 1.0,
00062         bool isRectified_ = false)
00063       {
00064         setup(directory_, prefix_+std::string("%0")+std::string(1,'0'+indexDigits_)+std::string("d")+suffix_,
00065           scale_, isBayerized_, width_, height_, depth_, first_, last_, step_, reduction, isRectified_);
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     }; // class ImageReader
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 /*      // for back compatibility purpose ; not compatible with swig for default parameters, ambiguity
00130       void setup(std::string directory_,
00131         std::string prefix_ = "image.",
00132         std::string leftSuffix_ = ".l",
00133         std::string rightSuffix_ = ".r",
00134         std::string suffix_ = ".tiff",
00135         unsigned int indexDigits_ = 4,
00136         double scale_ = 1.0,
00137         bool isBayerized_ = false,
00138         int width_ = -1, int height_ = -1, int depth_ = -1,
00139         int first_ = -1, int last_ = -1, int step_ = 1,
00140         double reduction = 1.0,
00141         bool isRectified_ = false)
00142       {
00143         setup(directory_, prefix_+leftSuffix_+std::string("%0")+std::string(1,'0'+indexDigits_)+std::string("d")+suffix_,
00144           prefix_+rightSuffix_+std::string("%0")+std::string(1,'0'+indexDigits_)+std::string("d")+suffix_,
00145           scale_ , isBayerized_, width_, height_, depth_, first_, last_, step_, reduction, isRectified_);
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     }; // class StereoImageReader
00165   }
00166 }
00167 #endif // IMAGE_IMAGE_READER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:17 for Jafar by doxygen 1.7.6.1
LAAS-CNRS