00001 #ifndef FCAM_SENSOR_H 00002 #define FCAM_SENSOR_H 00003 00006 00007 #include "Base.h" 00008 #include <vector> 00009 #include "Device.h" 00010 #include "Frame.h" 00011 00012 namespace FCam { 00013 00014 class Shot; 00015 00017 class Sensor : public Device { 00018 public: 00019 Sensor(); 00020 virtual ~Sensor(); 00021 00022 00024 virtual void capture(const Shot &) = 0; 00026 virtual void capture(const std::vector<Shot> &) = 0; 00027 00029 virtual void stream(const Shot &s) = 0; 00030 00032 virtual void stream(const std::vector<Shot> &) = 0; 00033 00035 virtual bool streaming() = 0; 00036 00040 virtual void stopStreaming() = 0; 00041 00045 virtual void start() = 0; 00046 00051 virtual void stop() = 0; 00052 00056 void setFrameLimit(int); 00057 00059 int getFrameLimit(); 00060 00062 enum DropPolicy {DropNewest = 0, 00063 DropOldest 00064 }; 00065 00067 void setDropPolicy(DropPolicy); 00068 00070 DropPolicy getDropPolicy(); 00071 00076 Frame getFrame() {return getBaseFrame();} 00077 00081 virtual int framesPending() const = 0; 00082 00089 virtual int shotsPending() const = 0; 00090 00093 void attach(Device *); 00094 00096 virtual int maxExposure() const = 0; 00097 00099 virtual int minExposure() const = 0; 00100 00102 virtual int maxFrameTime() const = 0; 00103 00105 virtual int minFrameTime() const = 0; 00106 00108 virtual float maxGain() const = 0; 00109 00111 virtual float minGain() const {return 1.0;} 00112 00114 virtual Size minImageSize() const = 0; 00115 00117 virtual Size maxImageSize() const {return Size(2592, 1968);} 00118 00120 virtual int maxHistogramRegions() const {return 4;} 00121 00124 virtual int rollingShutterTime(const Shot &) const = 0; 00125 00127 virtual BayerPattern bayerPattern() const = 0; 00128 00132 virtual void rawToRGBColorMatrix(int kelvin, float *matrix) const = 0; 00133 00135 virtual const std::string &manufacturer() const = 0; 00136 00138 virtual const std::string &model() const = 0; 00139 00141 virtual unsigned short minRawValue() const = 0; 00142 00144 virtual unsigned short maxRawValue() const = 0; 00145 00149 virtual void tagFrame(Frame) {}; 00150 00151 protected: 00152 std::vector<Device *> devices; 00153 00154 // Derived sensors should implement this method to return an 00155 // FCam::Frame, and also implement the non-virtual getFrame() 00156 // method and have it return a platform-specific frame type 00157 // (e.g. an FCam::N900::Frame). In this way, an N900::Sensor 00158 // can return an N900::Frame with getFrame, while casting it 00159 // to a base sensor will result in it returning base frames 00160 // (because getFrame is not virtual, and in the base class 00161 // just calls getBaseFrame) 00162 virtual Frame getBaseFrame() = 0; 00163 00164 // enforce the specified drop policy 00165 virtual void enforceDropPolicy() = 0; 00166 DropPolicy dropPolicy; 00167 size_t frameLimit; 00168 }; 00169 00170 } 00171 00172 #endif