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 const Platform &platform() = 0; 00128 00132 virtual void tagFrame(Frame) {}; 00133 00134 protected: 00135 std::vector<Device *> devices; 00136 00137 // Derived sensors should implement this method to return an 00138 // FCam::Frame, and also implement the non-virtual getFrame() 00139 // method and have it return a platform-specific frame type 00140 // (e.g. an FCam::N900::Frame). In this way, an N900::Sensor 00141 // can return an N900::Frame with getFrame, while casting it 00142 // to a base sensor will result in it returning base frames 00143 // (because getFrame is not virtual, and in the base class 00144 // just calls getBaseFrame) 00145 virtual Frame getBaseFrame() = 0; 00146 00147 // enforce the specified drop policy 00148 virtual void enforceDropPolicy() = 0; 00149 DropPolicy dropPolicy; 00150 size_t frameLimit; 00151 }; 00152 00153 } 00154 00155 #endif