00001 #ifndef _1394_CAMERA_H 00002 #define _1394_CAMERA_H 00003 00004 #include <WURDECam.H> 00005 #include <opencv/cv.h> 00006 #include <dc1394/dc1394_control.h> 00007 #include <vector> 00008 #include <string> 00009 #include <list> 00010 #include <Time.H> 00011 00012 #define MAX_1394_PORTS 4 00013 #define NUM_DMA_BUFFERS 8 00014 namespace WURDEVision { 00015 00026 class WURDE1394Camera : public WURDECamera { 00027 public: 00028 WURDE1394Camera(std::string name, std::map<std::string,std::string> camOptions); 00029 ~WURDE1394Camera(){stopCapture(); s_finder.freeCamera(m_id);} 00030 bool init(); 00031 bool startCapture(); 00032 void stopCapture(); 00033 00034 std::string getName(){return m_name;} 00035 u_int64_t getID(){return m_id;} 00036 00037 void setName(std::string value){m_name=value;} 00038 00042 WURDE::Time getTimestamp(){return m_timestamp;} 00043 00044 WURDE::WURDEImage captureYUV24(); 00045 WURDE::WURDEImage captureYUV422(); 00046 WURDE::WURDEImage captureGray(); 00047 WURDE::WURDEImage captureRGB(); 00048 00053 void resetFrame(); 00054 00055 00060 void setCameraDefaults(); 00061 00066 void setFramerate(dc1394framerate_t value){m_framerate=value;} 00067 00072 void setMode(dc1394video_mode_t value){m_mode=value;} 00073 00077 void setSpeed(dc1394speed_t value){m_speed=value;} 00078 00079 dc1394framerate_t getFramerate(){return m_framerate;} 00080 dc1394video_mode_t getMode(){return m_mode;} 00081 dc1394speed_t getSpeed(){return m_speed;} 00082 00083 00084 unsigned int getBrightness(); 00085 unsigned int getExposure(); 00086 unsigned int getSharpness(); 00087 unsigned int getHue(); 00088 unsigned int getSaturation(); 00089 unsigned int getGamma(); 00090 unsigned int getShutter(); 00091 unsigned int getGain(); 00092 unsigned int getIris(); 00093 unsigned int getFocus(); 00094 unsigned int getZoom(); 00095 unsigned int getTriggerDelay(); 00096 unsigned int getPan(); 00097 unsigned int getTilt(); 00098 unsigned int getOpticalFilter(); 00099 00100 bool setBrightness(unsigned int); 00101 bool setExposure(unsigned int); 00102 bool setSharpness(unsigned int); 00103 bool setHue(unsigned int); 00104 bool setSaturation(unsigned int); 00105 bool setGamma(unsigned int); 00106 bool setShutter(unsigned int); 00107 bool setGain(unsigned int); 00108 bool setIris(unsigned int); 00109 bool setAutoIris(bool value); 00110 bool setFocus(unsigned int); 00111 bool setTriggerMode(unsigned int); 00112 bool setZoom(unsigned int); 00113 bool setTriggerDelay(unsigned int value); 00114 bool setPan(unsigned int value); 00115 bool setTilt(unsigned int value); 00116 bool setOpticalFilter(unsigned int value); 00117 00118 void setCalibration(Calibration val){m_calib=val;} 00119 Calibration getCalibration(){return m_calib;} 00120 protected: 00125 class WURDE1394CameraFinder { 00126 public: 00127 WURDE1394CameraFinder(){} 00128 00129 void init(); 00130 dc1394camera_t *getCameraByID(u_int64_t id); 00131 void freeCamera(u_int64_t id){ 00132 if(m_cameras.find(id)!=m_cameras.end()){ 00133 dc1394_free_camera(m_cameras[id]); 00134 m_cameras.erase(id); 00135 } 00136 } 00137 // std::vector< WURDE1394Camera * > getAllCameras(); 00138 protected: 00139 00140 private: 00141 raw1394handle_t m_rawHandle; 00142 struct raw1394_portinfo m_ports[MAX_1394_PORTS]; 00143 int m_numPorts; 00144 int m_camCount; 00145 std::map<u_int64_t,dc1394camera_t *> m_cameras; 00146 }; 00147 00148 private: 00149 dc1394camera_t * m_camera; 00150 dc1394video_mode_t m_mode; 00151 dc1394framerate_t m_framerate; 00152 dc1394speed_t m_speed; 00153 u_int64_t m_id; 00154 static WURDE1394CameraFinder s_finder; 00155 00156 unsigned char *m_imBuffer; 00157 00158 WURDE::WURDEImage m_imageYUV422; 00159 bool m_haveYUV422; 00160 00161 WURDE::WURDEImage m_imageYUV24; 00162 bool m_haveYUV24; 00163 00164 WURDE::WURDEImage m_imageGray; 00165 bool m_haveGray; 00166 00167 WURDE::WURDEImage m_imageRGB; 00168 bool m_haveRGB; 00169 00170 WURDE::Time m_timestamp; 00171 }; 00172 00173 } 00174 00175 #endif