00001 #ifndef FCAM_FRAME_H 00002 #define FCAM_FRAME_H 00003 00007 #include <tr1/memory> 00008 #include <tr1/unordered_map> 00009 00010 #include "Base.h" 00011 #include "Device.h" 00012 #include "Time.h" 00013 #include "Image.h" 00014 #include "TagValue.h" 00015 #include "Shot.h" 00016 #include "Event.h" 00017 #include "Platform.h" 00018 00019 namespace FCam { 00020 00021 class Action; 00022 class Lens; 00023 00026 typedef std::tr1::unordered_map<std::string, TagValue> TagMap; 00027 00031 struct _Frame : public EventGenerator { 00032 _Frame(); 00033 virtual ~_Frame(); 00034 00035 Image image; 00036 Time exposureStartTime; 00037 Time exposureEndTime; 00038 Time processingDoneTime; 00039 int exposure; 00040 int frameTime; 00041 float gain; 00042 int whiteBalance; 00043 Histogram histogram; 00044 SharpnessMap sharpness; 00045 TagMap tags; 00046 00047 // Derived frames should implement these to return a 00048 // platform-specific shot with \ref Shot(), and a basic Shot 00049 // using \ref baseShot(). 00050 const Shot &shot() const { return baseShot(); } 00051 virtual const Shot &baseShot() const = 0; 00052 00053 // Derived frames should implement these to return static 00054 // platform data necessary for interpreting this frame. 00055 virtual const Platform &platform() const = 0; 00056 00059 virtual void debug(const char *name="") const; 00060 }; 00061 00068 class Frame { 00069 protected: 00070 std::tr1::shared_ptr<_Frame> ptr; 00071 00072 public: 00073 00078 Frame(_Frame *f=NULL) : ptr(f) {} 00079 00082 virtual ~Frame(); 00083 00085 bool valid() const {return (bool)ptr;} 00086 00088 bool operator==(const Frame &other) const { return ptr == other.ptr; } 00089 00092 Image image() const {return ptr->image;} 00093 00095 Time exposureStartTime() const {return ptr->exposureStartTime;} 00096 00099 Time exposureEndTime() const {return ptr->exposureEndTime;} 00100 00102 Time processingDoneTime() const {return ptr->processingDoneTime;} 00103 00107 int exposure() const {return ptr->exposure;} 00108 00115 int frameTime() const {return ptr->frameTime;} 00116 00121 float gain() const {return ptr->gain;} 00122 00125 int whiteBalance() const {return ptr->whiteBalance;} 00126 00130 const Histogram &histogram() const {return ptr->histogram;} 00131 00135 const SharpnessMap &sharpness() const {return ptr->sharpness;} 00136 00145 const Shot &shot() const { 00146 return ptr->shot(); 00147 } 00148 00155 const TagMap &tags() const { 00156 return ptr->tags; 00157 } 00158 00166 TagValue &operator[](const std::string &name) const { 00167 return ptr->tags[name]; 00168 } 00169 00172 virtual const Platform &platform() const { 00173 return ptr->platform(); 00174 } 00175 00180 operator EventGenerator *() { 00181 return static_cast<EventGenerator *>(ptr.get()); 00182 } 00183 00186 void debug(const char *name="") const { 00187 ptr->debug(name); 00188 } 00189 00190 }; 00191 00192 } 00193 00198 #define FCAM_FRAME_DEBUG(i) (i).debug(#i) 00199 00200 #endif