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

src/F2/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 { namespace F2 {
00014 
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     Histogram getHistogram(Time t, const HistogramConfig &conf);
00070     void setHistogramConfig(const HistogramConfig &);
00071 
00072     SharpnessMap getSharpnessMap(Time t, const SharpnessMapConfig &conf);
00073     void setSharpnessMapConfig(const SharpnessMapConfig &);
00074 
00075     int getFD();
00076        
00077       private:
00078     V4L2Sensor(std::string);
00079 
00080     Mode currentMode;
00081     SharpnessMapConfig currentSharpness;
00082     HistogramConfig currentHistogram;
00083 
00084     std::vector<V4L2Frame> buffers; 
00085 
00086     enum {CLOSED=0, IDLE, STREAMING} state;
00087     int fd;
00088 
00089     std::string filename;
00090 
00091     // there is one of these objects per device
00092     static std::map<std::string, V4L2Sensor *> instances_;
00093     };
00094 
00095 }}
00096 
00097 #endif
00098 

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