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

src/N900/V4L2Sensor.h

00001 #ifndef FCAM_V4L2_SENSOR_H
00002 #define FCAM_V4L2_SENSOR_H
00003 
00004 #include <vector>
00005 #include <string>
00006 #include <map>
00007 
00008 #include <FCam/Base.h>
00009 #include <FCam/Time.h>
00010 #include <FCam/Histogram.h>
00011 #include <FCam/SharpnessMap.h>
00012 
00013 namespace FCam {
00014     namespace N900 {
00015         // This class gives low-level control over the sensor using the
00016         // V4L2 interface. It is used by the user-visible sensor object to
00017         // control the sensor
00018         
00019         class V4L2Sensor {
00020         public:
00021             
00022             struct V4L2Frame {
00023                 Time processingDoneTime;
00024                 unsigned char *data;
00025                 size_t length; // in bytes
00026                 int index;    
00027             };
00028             
00029             struct Mode {
00030                 int width, height;
00031                 ImageFormat type;
00032             };
00033             
00034             static V4L2Sensor *instance(std::string);
00035             
00036             // open and close the device
00037             void open();
00038             void close();
00039             
00040             // start and stop streaming
00041             void startStreaming(Mode, 
00042                                 const HistogramConfig &,
00043                                 const SharpnessMapConfig &);
00044             void stopStreaming();
00045             
00046             V4L2Frame *acquireFrame(bool blocking);
00047             void releaseFrame(V4L2Frame *frame);
00048             
00049             Mode getMode() {return currentMode;}
00050             
00051             enum Errors {
00052                 InvalidId,
00053                 OutOfRangeValue,
00054                 ControlBusy
00055             };
00056             
00057             void setControl(unsigned int id, int value);
00058             int getControl(unsigned int id);
00059             
00060             void setExposure(int);
00061             int getExposure();
00062             
00063             void setFrameTime(int);
00064             int getFrameTime();
00065             
00066             void setGain(float);
00067             float getGain();
00068 
00069             void setWhiteBalance(const float *);
00070             
00071             Histogram getHistogram(Time t, const HistogramConfig &conf);
00072             void setHistogramConfig(const HistogramConfig &);
00073             
00074             SharpnessMap getSharpnessMap(Time t, const SharpnessMapConfig &conf);
00075             void setSharpnessMapConfig(const SharpnessMapConfig &);
00076             
00077             int getFD();
00078             
00079           private:
00080             V4L2Sensor(std::string);
00081             
00082             Mode currentMode;
00083             SharpnessMapConfig currentSharpness;
00084             HistogramConfig currentHistogram;
00085             
00086             std::vector<V4L2Frame> buffers;        
00087             
00088             enum {CLOSED=0, IDLE, STREAMING} state;
00089             int fd;
00090             
00091             std::string filename;
00092             
00093             // there is one of these objects per device
00094             static std::map<std::string, V4L2Sensor *> instances_;
00095         };
00096     }
00097 }
00098 
00099 #endif
00100 

Generated on Fri Sep 24 2010 15:53:00 for FCam by  doxygen 1.7.1