• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

include/FCam/Frame.h

Go to the documentation of this file.
00001 #ifndef FCAM_FRAME_H
00002 #define FCAM_FRAME_H
00003 
00007 #include <tr1/memory>
00008 #ifndef FCAM_PLATFORM_OSX
00009 #include <tr1/unordered_map>
00010 #else
00011 #include <map>
00012 #endif
00013 
00014 #include "Base.h"
00015 #include "Device.h"
00016 #include "Time.h"
00017 #include "Image.h"
00018 #include "TagValue.h"
00019 #include "Shot.h"
00020 #include "Event.h"
00021 
00022 namespace FCam {
00023 
00024     class Action;
00025     class Lens;
00026 
00029 #ifndef FCAM_PLATFORM_OSX // g++ 4.0.1 (OSX 10.5) has a bug in unordered_map
00030     typedef std::tr1::unordered_map<std::string, TagValue> TagMap;
00031 #else
00032     typedef std::map<std::string, TagValue> TagMap;
00033 #endif
00034 
00038     struct _Frame : public EventGenerator {
00039         _Frame();
00040     virtual ~_Frame();
00041 
00042         Image image;
00043         Time exposureStartTime;
00044         Time exposureEndTime;    
00045         Time processingDoneTime; 
00046         int exposure; 
00047         int frameTime; 
00048         float gain;    
00049         int whiteBalance;
00050         Histogram histogram;    
00051         SharpnessMap sharpness;   
00052         TagMap tags;
00053 
00054         // Derived frames should implement these to return a
00055         // platform-specific shot with \ref Shot(), and a basic Shot
00056         // using \ref baseShot().
00057         const Shot &shot() const { return baseShot(); }
00058         virtual const Shot &baseShot() const = 0;
00059 
00060         // Derived frames should implement these to return static
00061         // platform data necessary for interpreting this frame.
00062         virtual BayerPattern bayerPattern() const = 0;
00063         virtual unsigned short minRawValue() const {return 0;}
00064         virtual unsigned short maxRawValue() const = 0; 
00065         virtual void rawToRGBColorMatrix(int kelvin, float *matrix) const = 0;
00066         virtual const std::string &manufacturer() const = 0;
00067         virtual const std::string &model() const = 0;
00068 
00071         virtual void debug(const char *name="") const;
00072     };
00073 
00080     class Frame {
00081     protected:
00082         std::tr1::shared_ptr<_Frame> ptr;
00083 
00084     public:
00085 
00090         Frame(_Frame *f=NULL) : ptr(f) {}
00091 
00094     virtual ~Frame() {}
00095 
00097         bool valid() const {return (bool)ptr;}
00098 
00100         bool operator==(const Frame &other) const { return ptr == other.ptr; }
00101 
00104         Image image() const {return ptr->image;}
00105         
00107         Time exposureStartTime() const {return ptr->exposureStartTime;}
00108         
00111         Time exposureEndTime() const {return ptr->exposureEndTime;}    
00112 
00114         Time processingDoneTime() const {return ptr->processingDoneTime;}
00115 
00119         int exposure() const {return ptr->exposure;}
00120 
00127         int frameTime() const {return ptr->frameTime;}
00128         
00133         float gain() const {return ptr->gain;}
00134                
00137         int whiteBalance() const {return ptr->whiteBalance;}
00138 
00142         const Histogram &histogram() const {return ptr->histogram;}
00143 
00147         const SharpnessMap &sharpness() const {return ptr->sharpness;}
00148 
00157         const Shot &shot() const {
00158             return ptr->shot();
00159         }
00160 
00167         const TagMap &tags() const {
00168             return ptr->tags;
00169         }
00170 
00178         TagValue &operator[](const std::string &name) const {
00179             return ptr->tags[name];
00180         }
00181 
00187         void rawToRGBColorMatrix(float *matrix) const {
00188             return ptr->rawToRGBColorMatrix(ptr->whiteBalance, matrix);
00189         }
00190         
00193         virtual BayerPattern bayerPattern() const {
00194             return ptr->bayerPattern();
00195         }
00196 
00199         virtual unsigned short minRawValue() const {
00200             return ptr->minRawValue();
00201         }
00202 
00205         virtual unsigned short maxRawValue() const {
00206             return ptr->maxRawValue();
00207         }
00208 
00212         virtual void rawToRGBColorMatrix(int kelvin, float *matrix) const {
00213             return ptr->rawToRGBColorMatrix(kelvin, matrix);
00214         }
00215 
00218         virtual const std::string &manufacturer() const {
00219             return ptr->manufacturer();
00220         }
00221 
00224         virtual const std::string &model() const {
00225             return ptr->model();
00226         }
00227 
00232         operator EventGenerator*() {
00233             return static_cast<EventGenerator *>(ptr.get());
00234         }
00235 
00238         void debug(const char *name="") const {
00239             ptr->debug(name);
00240         }
00241 
00242     };
00243 
00244 }
00245 
00250 #define FCAM_FRAME_DEBUG(i) (i).debug(#i)
00251 
00252 #endif

Generated on Thu Jul 15 2010 17:51:28 for FCam by  doxygen 1.7.1