00001 #ifndef _1394_CAMERA_H 00002 #define _1394_CAMERA_H 00003 00004 #include <opencv/cv.h> 00005 #include <dc1394/dc1394_control.h> 00006 #include <vector> 00007 #include <string> 00008 #include <list> 00009 #include <Time.H> 00010 00011 #define MAX_1394_PORTS 4 00012 #define NUM_DMA_BUFFERS 8 00013 namespace RobotVision { 00014 00021 void convert_yuv411_to_yuv24(IplImage *img, unsigned char *src); 00022 00029 void convert_yuv422_to_yuv24(IplImage *img, unsigned char *src); 00030 00037 void convert_yuv411_to_gray(IplImage *img, unsigned char *src); 00038 void convert_yuv422_to_gray(IplImage *img, unsigned char *src); 00039 00040 struct Calibration { 00041 int centerX; 00042 int centerY; 00043 double focalLength; 00044 }; 00045 00056 class WURDE1394Camera { 00057 public: 00058 WURDE1394Camera(dc1394camera_t *cameraStruct); 00059 ~WURDE1394Camera(){stopCapture();} 00060 bool init(); 00061 bool startCapture(); 00062 void stopCapture(); 00063 00064 std::string getName(){return m_name;} 00065 u_int64_t getID(){return m_camera->euid_64;} 00066 00067 void setName(std::string value){m_name=value;} 00068 00072 WURDE::Time getTimestamp(){return m_timestamp;} 00073 00074 IplImage *captureYUV24(); 00075 IplImage *captureYUV422(); 00076 IplImage *captureGray(); 00077 IplImage *captureRGB(); 00078 00083 void resetFrame(); 00084 00085 00090 void setCameraDefaults(); 00091 00096 void setFramerate(dc1394framerate_t value){m_framerate=value;} 00097 00102 void setMode(dc1394video_mode_t value){m_mode=value;} 00103 00107 void setSpeed(dc1394speed_t value){m_speed=value;} 00108 00109 dc1394framerate_t getFramerate(){return m_framerate;} 00110 dc1394video_mode_t getMode(){return m_mode;} 00111 dc1394speed_t getSpeed(){return m_speed;} 00112 00113 00114 unsigned int getBrightness(); 00115 unsigned int getExposure(); 00116 unsigned int getSharpness(); 00117 unsigned int getHue(); 00118 unsigned int getSaturation(); 00119 unsigned int getGamma(); 00120 unsigned int getShutter(); 00121 unsigned int getGain(); 00122 unsigned int getIris(); 00123 unsigned int getFocus(); 00124 unsigned int getZoom(); 00125 unsigned int getTriggerDelay(); 00126 unsigned int getPan(); 00127 unsigned int getTilt(); 00128 unsigned int getOpticalFilter(); 00129 00130 bool setBrightness(unsigned int); 00131 bool setExposure(unsigned int); 00132 bool setSharpness(unsigned int); 00133 bool setHue(unsigned int); 00134 bool setSaturation(unsigned int); 00135 bool setGamma(unsigned int); 00136 bool setShutter(unsigned int); 00137 bool setGain(unsigned int); 00138 bool setIris(unsigned int); 00139 bool setAutoIris(bool value); 00140 bool setFocus(unsigned int); 00141 bool setTriggerMode(unsigned int); 00142 bool setZoom(unsigned int); 00143 bool setTriggerDelay(unsigned int value); 00144 bool setPan(unsigned int value); 00145 bool setTilt(unsigned int value); 00146 bool setOpticalFilter(unsigned int value); 00147 00148 void setCalibration(Calibration val){m_calib=val;} 00149 Calibration getCalibration(){return m_calib;} 00150 protected: 00151 00152 private: 00153 std::string m_name; 00154 00155 dc1394camera_t * m_camera; 00156 00157 dc1394video_mode_t m_mode; 00158 dc1394framerate_t m_framerate; 00159 dc1394speed_t m_speed; 00160 00161 bool m_haveFrame; 00162 bool m_init; 00163 unsigned char *m_imBuffer; 00164 00165 IplImage *m_imageYUV422; 00166 bool m_haveYUV422; 00167 00168 IplImage *m_imageYUV24; 00169 bool m_haveYUV24; 00170 00171 IplImage *m_imageGray; 00172 bool m_haveGray; 00173 00174 IplImage *m_imageRGB; 00175 bool m_haveRGB; 00176 00177 WURDE::Time m_timestamp; 00178 00179 Calibration m_calib; 00180 00181 }; 00182 00187 class WURDECameraFinder { 00188 public: 00189 WURDECameraFinder(){} 00190 00191 void init(); 00192 RobotVision::WURDE1394Camera *getCameraByID(u_int64_t id); 00193 std::vector< RobotVision::WURDE1394Camera * > getAllCameras(); 00194 protected: 00195 00196 private: 00197 raw1394handle_t m_rawHandle; 00198 struct raw1394_portinfo m_ports[MAX_1394_PORTS]; 00199 int m_numPorts; 00200 int m_camCount; 00201 }; 00202 00203 } 00204 00205 //static std::list< RobotVision::WURDE1394Camera * > _robotVision_global_cameraList; 00206 //void _robotVision_global_cleanUpCameraList(); 00207 00208 #endif