/home/fwph/code/wurde/rde/utils/WURDE1394Camera.cpp

Go to the documentation of this file.
00001 #include <WURDECam.H>
00002 #include <WURDE1394Camera.H>
00003 #include <Logger.H>
00004 #include <signal.h>
00005 #include <dc1394/dc1394_conversions.h>
00006 #include <dc1394/dc1394_control.h>
00007 
00008 using namespace std;
00009 using namespace WURDE;
00010 using namespace WURDEVision;
00011 
00012 WURDE1394Camera::WURDE1394CameraFinder WURDE1394Camera::s_finder;
00013 
00014 void WURDE1394Camera::WURDE1394CameraFinder::init(){
00015 
00016 }
00017 
00018 dc1394camera_t *WURDE1394Camera::WURDE1394CameraFinder::getCameraByID(u_int64_t id){
00019         //      WURDE1394Camera *retval=NULL;
00020         dc1394camera_t *retval=NULL;
00021         dc1394camera_t **cameras=NULL;
00022         
00023         unsigned int numCameras, err=dc1394_find_cameras(&cameras, &numCameras);
00024         
00025         if (err!=DC1394_SUCCESS) {
00026                 fprintf( stderr, "Unable to look for cameras\n\n"
00027                          "Please check \n"
00028                          "  - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
00029                          "  - if you have read/write access to /dev/raw1394\n\n");
00030                 exit(1);
00031         }
00032         
00033         if (numCameras<1) {
00034                 fprintf(stderr, "no cameras found :(\n");
00035                 exit(1);
00036         }
00037         g_debug("Looking for the camera..");
00038         for(unsigned int i=0;i<numCameras;i++){
00039                 cout << cameras[i]->euid_64 << " looking for " << id << endl;
00040                 if(cameras[i]->euid_64==id){
00041                         g_debug("Found the cam");
00042                         retval=cameras[i];
00043                         m_cameras[id]=retval;
00044                         //                      retval=new WURDE1394Camera(cameras[i]);
00045                 }else{
00046                         g_debug("Not this camera.");
00047                         dc1394_free_camera(cameras[i]);
00048                 }
00049         }
00050         
00051         return retval;
00052         
00053 }
00054 
00055 /**************************************************************************************/
00056 
00057 WURDE1394Camera::WURDE1394Camera(std::string name, std::map<std::string,std::string> camOptions) :
00058         WURDECamera(name,camOptions){
00059         m_camera=NULL;
00060         
00061         //sensible defaults
00062         m_mode=DC1394_VIDEO_MODE_320x240_YUV422;
00063         m_framerate=DC1394_FRAMERATE_30;
00064         m_speed=DC1394_ISO_SPEED_400;
00065         
00066         m_imBuffer=NULL;
00067         m_init=false;
00068         //      _robotVision_global_cameraList.push_back(this);
00069         if(m_options.find("id")!=m_options.end()){
00070                 m_id=strtoull(m_options["id"].c_str(),NULL,0);
00071                 m_camera=s_finder.getCameraByID(m_id);          
00072         }else{
00073                 g_logerror << "Initializing a firewire camera called " << m_name << " but have no id number to find it with!" << endl;
00074         }
00075         if(!m_camera){
00076                 g_logerror << "Unable to obtain firewire camera " << m_name << " with id: " << camOptions["id"] << endl;
00077                 m_haveCam=false;
00078         }else{
00079                 m_haveCam=true;
00080         }
00081        
00082         m_haveYUV24=false;
00083         m_haveYUV422=false;
00084         m_haveGray=false;
00085         m_haveRGB=false;
00086 
00087         m_imageYUV24.second=NULL;
00088         m_imageYUV422.second=NULL;
00089         m_imageRGB.second=NULL;
00090         m_imageGray.second=NULL;
00091 }
00092 
00093 bool WURDE1394Camera::init(){
00094        
00095        if(!m_init){
00096               dc1394_video_set_iso_speed(m_camera, m_speed);
00097               dc1394_video_set_mode(m_camera, m_mode);
00098               dc1394_video_set_framerate(m_camera, m_framerate);
00099               
00100               if(m_options.find("brightness")!=m_options.end()){
00101                      setBrightness (strtol(m_options["brightness"].c_str(),NULL,10));
00102               }
00103 
00104               if(m_options.find("exposure")!=m_options.end()){
00105                      setExposure (strtol(m_options["exposure"].c_str(),NULL,10));
00106               }
00107 
00108               if(m_options.find("sharpness")!=m_options.end()){
00109                      setSharpness (strtol(m_options["sharpness"].c_str(),NULL,10));
00110               }
00111 
00112               if(m_options.find("hue")!=m_options.end()){
00113                      setHue (strtol(m_options["hue"].c_str(),NULL,10));
00114               }
00115 
00116               if(m_options.find("saturation")!=m_options.end()){
00117                      setSaturation (strtol(m_options["saturation"].c_str(),NULL,10));
00118               }
00119 
00120               if(m_options.find("gamma")!=m_options.end()){
00121                      setGamma (strtol(m_options["gamma"].c_str(),NULL,10));
00122               }
00123 
00124               if(m_options.find("shutter")!=m_options.end()){
00125                      setShutter (strtol(m_options["shutter"].c_str(),NULL,10));
00126               }
00127 
00128               if(m_options.find("gain")!=m_options.end()){
00129                      setGain (strtol(m_options["gain"].c_str(),NULL,10));
00130               }
00131 
00132               if(m_options.find("iris")!=m_options.end()){
00133                      setIris (strtol(m_options["iris"].c_str(),NULL,10));
00134               }
00135 
00136               if(m_options.find("focus")!=m_options.end()){
00137                      setFocus (strtol(m_options["focus"].c_str(),NULL,10));
00138               }
00139 
00140               if(m_options.find("zoom")!=m_options.end()){
00141                      setZoom (strtol(m_options["zoom"].c_str(),NULL,10));      
00142               }
00143 
00144               if(m_options.find("autoiris")!=m_options.end()){
00145                      if(m_options["autoiris"]=="true"){
00146                             setAutoIris(true);
00147                      }else{
00148                             setAutoIris(false);
00149                      }
00150               }
00151 
00152 
00153        }
00154        m_init=true;
00155        return true;
00156 }
00157 
00158 bool WURDE1394Camera::startCapture(){
00159 
00160        init();
00161 
00162        if (dc1394_capture_setup_dma(m_camera,NUM_DMA_BUFFERS,1)!=DC1394_SUCCESS) {
00163                g_logwarn << "Camera " << m_name << " not responding... Attempting to reset." << endl;
00164                stopCapture();
00165                if (dc1394_capture_setup_dma(m_camera,NUM_DMA_BUFFERS,1)!=DC1394_SUCCESS) {
00166                        g_error("Unable to setup the camera, check modes");
00167                        return false;
00168                }
00169        }
00170 
00171 
00172        if (dc1394_video_set_transmission(m_camera, DC1394_ON) !=DC1394_SUCCESS) {
00173               g_error("Unable to start transmission");
00174               return false;
00175        }
00176  
00177        dc1394switch_t status = DC1394_OFF;
00178 
00179        int i = 0;
00180        while( status == DC1394_OFF && i++ < 5 ) {
00181               usleep(50000);
00182               if (dc1394_video_get_transmission(m_camera, &status)!=DC1394_SUCCESS) {
00183                      g_error("Unable to get transmission status");
00184                      return false;
00185               }
00186        }
00187 
00188        if( i == 5 ) {
00189               g_error("Camera isn't turning on...");
00190               return false;
00191        }
00192        
00193        return true;
00194 }
00195 
00196 void WURDE1394Camera::stopCapture(){
00197 
00198        if (dc1394_video_set_transmission(m_camera, DC1394_OFF) !=DC1394_SUCCESS) {
00199               //              g_error("Unable to stop transmission");
00200        }
00201 
00202        if (dc1394_capture_stop(m_camera) !=DC1394_SUCCESS) {
00203               //              g_error("Unable to stop camera");
00204        }
00205        /*
00206        std::list<RobotVision::WURDE1394Camera *>::iterator iter;
00207        for(iter=_robotVision_global_cameraList.begin();
00208            iter!=_robotVision_global_cameraList.end();
00209            iter++){
00210               if((*iter)==this){
00211                      _robotVision_global_cameraList.erase(iter);
00212                      break;
00213               }
00214        }
00215        */
00216 }
00217 
00218 WURDEImage WURDE1394Camera::captureYUV24(){
00219         // Returning an image that has 8 bpp, 3 channels (y,u,v)
00220         // Known users of this format: 
00221         //   + CMVision
00222         g_wurdeCamErrno=ERROR_NOERROR;
00223        g_debug("Capturing YUV24..");
00224        if(m_haveYUV24){
00225               g_debug("Already have one. Returning.");
00226               return m_imageYUV24;
00227        }
00228 
00229        if(!m_haveFrame||!m_imBuffer){
00230               g_debug("Capturing new frame.");
00231               if(dc1394_capture_dma (&m_camera, 1, DC1394_VIDEO1394_WAIT)!=DC1394_SUCCESS){
00232                    g_error("Unable to capture a frame from the camera");
00233                    m_imageYUV24.second=NULL;
00234                    
00235                    return m_imageYUV24;
00236               }
00237               m_timestamp.now();
00238               m_imBuffer=dc1394_capture_get_dma_buffer(m_camera);
00239               char buffer[1024];
00240               sprintf(buffer,"new timestamp: %ld, %ld",m_timestamp.getSeconds(),m_timestamp.getUSeconds());
00241               g_debug(buffer);
00242 
00243               if(m_imBuffer){         
00244                      m_haveFrame=true;
00245               }else{
00246 
00247                      g_warn("Didn't get a frame this time");
00248                      m_imageYUV24.second=NULL;
00249                      g_wurdeCamErrno=ERROR_IMAGE_NOT_AVAILABLE;              
00250                      return m_imageYUV24;
00251               }
00252 
00253        }
00254 
00255        m_imageYUV24.first=m_timestamp;
00256 
00257        if(!m_haveYUV24){
00258               g_debug("Converting....");
00259               switch(m_mode){
00260               case DC1394_VIDEO_MODE_640x480_YUV411:
00261                      if(!m_imageYUV24.second){
00262                             m_imageYUV24.second=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3);
00263                      }
00264                      convert_yuv411_to_yuv24(m_imageYUV24.second, (unsigned char*) m_imBuffer);
00265                      break;
00266               case DC1394_VIDEO_MODE_640x480_YUV422:
00267                      if(!m_imageYUV24.second){
00268                             m_imageYUV24.second=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3);
00269                      }
00270                      convert_yuv422_to_yuv24(m_imageYUV24.second, (unsigned char*) m_imBuffer);
00271                      break;
00272               case DC1394_VIDEO_MODE_320x240_YUV422:
00273                      if(!m_imageYUV24.second){
00274                             m_imageYUV24.second=cvCreateImage(cvSize(320, 240), IPL_DEPTH_8U, 3);
00275                      }
00276                      convert_yuv422_to_yuv24(m_imageYUV24.second, (unsigned char*) m_imBuffer);
00277                      break;
00278               case DC1394_VIDEO_MODE_160x120_YUV444:                 
00279               default:
00280                      g_error("An unsupported (by this library) mode was requested");
00281                      g_wurdeCamErrno=ERROR_UNSUPPORTED_IMAGE_TYPE;
00282                      m_imageYUV24.second=NULL;
00283                      return m_imageYUV24;
00284                      break;
00285               }
00286        }
00287 
00288        m_haveYUV24=true;
00289 
00290        return m_imageYUV24;
00291 }
00292 
00293 WURDEImage WURDE1394Camera::captureGray(){
00294         g_wurdeCamErrno=ERROR_NOERROR;
00295        if(m_haveGray){
00296               return m_imageGray;
00297        }
00298        
00299        if(!m_haveFrame||!m_imBuffer){
00300               if(dc1394_capture_dma(&m_camera, 1, DC1394_VIDEO1394_WAIT)!=DC1394_SUCCESS){
00301                      g_error("Unable to capture a frame from the camera");
00302                      return m_imageGray;
00303               }
00304               m_timestamp.now();
00305               m_imBuffer=dc1394_capture_get_dma_buffer(m_camera);
00306 
00307               if(m_imBuffer){         
00308                      m_haveFrame=true;
00309               }else{
00310                       g_wurdeCamErrno=ERROR_IMAGE_NOT_AVAILABLE;
00311                      g_warn("Didn't get a frame this time");
00312                      return m_imageGray;
00313               }
00314        }
00315 
00316        m_imageGray.first=m_timestamp;
00317 
00318        if(!m_haveGray){
00319               switch(m_mode){
00320               case DC1394_VIDEO_MODE_640x480_YUV411:
00321                      if(!m_imageGray.second){
00322                             m_imageGray.second=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 1);
00323                      }
00324                      convert_yuv411_to_gray(m_imageGray.second, m_imBuffer);
00325 
00326                      break;
00327               case DC1394_VIDEO_MODE_640x480_YUV422:
00328                      if(!m_imageGray.second){
00329                             m_imageGray.second=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 1);
00330                      }  
00331                      convert_yuv422_to_gray(m_imageGray.second, m_imBuffer);
00332                      
00333                      break;
00334               case DC1394_VIDEO_MODE_320x240_YUV422:
00335                      if(!m_imageGray.second){
00336                             m_imageGray.second=cvCreateImage(cvSize(320, 240), IPL_DEPTH_8U, 1);
00337                      }
00338                      convert_yuv422_to_gray(m_imageGray.second, m_imBuffer);
00339 
00340                      break;
00341               case DC1394_VIDEO_MODE_160x120_YUV444:                 
00342                      if(!m_imageGray.second){
00343                             m_imageGray.second=cvCreateImage(cvSize(160, 120), IPL_DEPTH_8U, 1);
00344                      }
00345                      dc1394_convert_to_MONO8(m_imBuffer,(unsigned char *)m_imageGray.second->imageData,160,120,DC1394_BYTE_ORDER_UYVY,DC1394_COLOR_CODING_YUV444,8);
00346                      break;
00347               default:
00348                       g_wurdeCamErrno=ERROR_UNSUPPORTED_IMAGE_TYPE;
00349                      g_error("An unsupported (by this library) mode/image combination was requested");
00350                      return m_imageGray;
00351                      break;
00352               }
00353        }
00354        
00355        m_haveGray=true;
00356        return m_imageGray;
00357 }
00358 
00359 WURDEImage WURDE1394Camera::captureYUV422(){
00360         g_wurdeCamErrno=ERROR_NOERROR;
00361         //#warning No conversion from YUV411 to YUV422       
00362        if(m_haveYUV422){
00363               return m_imageYUV422;
00364        }
00365 
00366        if(!m_haveFrame||!m_imBuffer){
00367               if(dc1394_capture_dma(&m_camera, 1, DC1394_VIDEO1394_WAIT)!=DC1394_SUCCESS){
00368                      g_error("Unable to capture a frame from the camera");
00369                      return m_imageYUV422;
00370               }
00371               m_timestamp.now();
00372               m_imBuffer=dc1394_capture_get_dma_buffer(m_camera);
00373 
00374               if(m_imBuffer){         
00375                      m_haveFrame=true;
00376               }else{
00377                       g_wurdeCamErrno=ERROR_IMAGE_NOT_AVAILABLE;
00378                      g_warn("Didn't get a frame this time");
00379                      return m_imageYUV422;
00380               }
00381        }
00382         
00383        m_imageYUV422.first=m_timestamp;
00384 
00385        if(!m_haveYUV422){
00386               switch(m_mode){
00387               case DC1394_VIDEO_MODE_640x480_YUV411:
00388                      /*              if(!m_imageYUV24){
00389                             m_imageYUV24=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3);
00390                      }
00391                      convert_yuv411_to_yuv24(m_imageYUV24, (unsigned char*) m_imBuffer);
00392                      */
00393                      g_error("YUV411 capture to YUV422 image conversion not currently supported");
00394                      return m_imageYUV422;
00395                      break;
00396               case DC1394_VIDEO_MODE_640x480_YUV422:
00397                      if(!m_imageYUV422.second){
00398                             m_imageYUV422.second=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 2);
00399                      }
00400                      memcpy(m_imageYUV422.second->imageData,m_imBuffer,640*480*2);
00401                      break;
00402               case DC1394_VIDEO_MODE_320x240_YUV422:
00403                      if(!m_imageYUV422.second){
00404                             m_imageYUV422.second=cvCreateImage(cvSize(320, 240), IPL_DEPTH_8U, 2);
00405                      }
00406                      memcpy(m_imageYUV422.second->imageData,m_imBuffer,320*240*2);
00407                      break;
00408               case DC1394_VIDEO_MODE_160x120_YUV444:                 
00409               default:
00410                       g_wurdeCamErrno=ERROR_UNSUPPORTED_IMAGE_TYPE;
00411                      g_error("An unsupported (by this library) mode was requested");
00412                      return m_imageYUV422;
00413                      break;
00414               }
00415        }
00416        
00417        m_haveYUV422=true;
00418        return m_imageYUV422;
00419 }
00420 
00421 WURDEImage WURDE1394Camera::captureRGB(){
00422         g_wurdeCamErrno=ERROR_NOERROR;
00423        if(m_haveRGB){
00424               return m_imageRGB;
00425        }
00426        
00427        if(!m_haveFrame||!m_imBuffer){
00428               if(dc1394_capture_dma(&m_camera, 1, DC1394_VIDEO1394_WAIT)!=DC1394_SUCCESS){
00429                      g_error("Unable to capture a frame from the camera");
00430                      return m_imageRGB;
00431               }
00432               m_timestamp.now();
00433               m_imBuffer=dc1394_capture_get_dma_buffer(m_camera);
00434 
00435               if(m_imBuffer){         
00436                      m_haveFrame=true;
00437               }else{
00438                       g_wurdeCamErrno=ERROR_IMAGE_NOT_AVAILABLE;
00439                      g_warn("Didn't get a frame this time");
00440                      return m_imageRGB;
00441               }
00442        }
00443        
00444        m_imageRGB.first=m_timestamp;
00445 
00446        if(!m_haveRGB){
00447               switch(m_mode){
00448               case DC1394_VIDEO_MODE_640x480_YUV411:
00449                      if(!m_imageRGB.second){
00450                             m_imageRGB.second=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3);
00451                      }
00452                      dc1394_convert_to_RGB8(m_imBuffer,(unsigned char *)m_imageRGB.second->imageData,640,480,DC1394_BYTE_ORDER_UYVY,DC1394_COLOR_CODING_YUV411,16);
00453                      break;
00454               case DC1394_VIDEO_MODE_640x480_YUV422:
00455                      if(!m_imageRGB.second){
00456                             m_imageRGB.second=cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3);
00457                      }                
00458                      dc1394_convert_to_RGB8(m_imBuffer,(unsigned char *)m_imageRGB.second->imageData,640,480,DC1394_BYTE_ORDER_UYVY,DC1394_COLOR_CODING_YUV422,16);
00459 
00460                      break;
00461               case DC1394_VIDEO_MODE_320x240_YUV422:
00462                      if(!m_imageRGB.second){
00463                             m_imageRGB.second=cvCreateImage(cvSize(320, 240), IPL_DEPTH_8U, 3);
00464                      }
00465                      dc1394_convert_to_RGB8(m_imBuffer,(unsigned char *)m_imageRGB.second->imageData,320,240,DC1394_BYTE_ORDER_UYVY,DC1394_COLOR_CODING_YUV422,16);
00466                      break;
00467               case DC1394_VIDEO_MODE_160x120_YUV444:                 
00468                      if(!m_imageRGB.second){
00469                             m_imageRGB.second=cvCreateImage(cvSize(160, 120), IPL_DEPTH_8U, 3);
00470                      }
00471                      dc1394_convert_to_RGB8(m_imBuffer,(unsigned char *)m_imageRGB.second->imageData,160,120,DC1394_BYTE_ORDER_UYVY,DC1394_COLOR_CODING_YUV444,16);
00472                      break;
00473               default:
00474                       g_wurdeCamErrno=ERROR_UNSUPPORTED_IMAGE_TYPE;
00475                      g_error("An unsupported (by this library) mode/image combination was requested");
00476                      return m_imageRGB;
00477                      break;
00478               }
00479        }
00480        
00481        m_haveRGB=true;
00482        return m_imageRGB;
00483 }
00484 
00485 
00486 void WURDE1394Camera::resetFrame(){
00487        if(m_haveFrame){
00488               g_debug("Releasing buffer");
00489               if(dc1394_capture_dma_done_with_buffer(m_camera)!=DC1394_SUCCESS){
00490                      g_error("Error releasing the DMA buffer!");
00491               }
00492        }
00493        m_haveFrame=false;
00494        m_haveYUV422=false;
00495        m_haveYUV24=false;
00496        m_haveGray=false;
00497        m_haveRGB=false;
00498        m_imBuffer=NULL;
00499 }
00500 
00501 void WURDE1394Camera::setCameraDefaults(){
00502         setBrightness (1024);
00503         setExposure (128);
00504         setSharpness (128);
00505         //       setWhiteBalance (128,128);
00506         setHue (128);
00507         setSaturation (128);
00508         setGamma (128);
00509         setShutter (2048);
00510         setGain (0);
00511         setIris (2048);
00512         setFocus (256);
00513         setZoom (0);      
00514         setAutoIris(true);
00515         
00516 }
00517 
00518 unsigned int WURDE1394Camera::getBrightness(){
00519         unsigned int value;
00520         
00521         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_BRIGHTNESS, &value)!=DC1394_SUCCESS){
00522                 g_error("Unable to get camera brightness.");
00523                 return 0;
00524         }
00525         
00526         return value;
00527         
00528 }
00529 
00530 unsigned int WURDE1394Camera::getExposure(){
00531         unsigned int value;
00532         
00533         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_EXPOSURE, &value)!=DC1394_SUCCESS){
00534                 g_error("Unable to get camera exposure.");
00535                 return 0;
00536         }
00537         
00538         return value;
00539 }
00540 
00541 unsigned int WURDE1394Camera::getSharpness(){
00542         unsigned int value;
00543         
00544         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_SHARPNESS, &value)!=DC1394_SUCCESS){
00545                 g_error("Unable to get camera sharpness.");
00546                 return 0;
00547         }
00548         
00549         return value;
00550 }
00551 
00552 unsigned int WURDE1394Camera::getHue(){
00553         unsigned int value;
00554         
00555         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_HUE, &value)!=DC1394_SUCCESS){
00556                 g_error("Unable to get camera hue.");
00557                 return 0;
00558         }
00559         
00560         return value;
00561 }
00562 
00563 unsigned int WURDE1394Camera::getSaturation(){
00564         unsigned int value;
00565         
00566         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_SATURATION, &value)!=DC1394_SUCCESS){
00567                 g_error("Unable to get camera saturation.");
00568                 return 0;
00569         }
00570         
00571         return value;
00572 }
00573 
00574 unsigned int WURDE1394Camera::getGamma(){
00575         unsigned int value;
00576         
00577         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_GAMMA, &value)!=DC1394_SUCCESS){
00578                 g_error("Unable to get camera gamma.");
00579                 return 0;
00580         }
00581         
00582         return value;
00583 }
00584 
00585 unsigned int WURDE1394Camera::getShutter(){
00586         unsigned int value;
00587         
00588         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_SHUTTER, &value)!=DC1394_SUCCESS){
00589                 g_error("Unable to get camera shutter.");
00590                 return 0;
00591         }
00592         
00593         return value;
00594 }
00595 
00596 unsigned int WURDE1394Camera::getGain(){
00597         unsigned int value;
00598         
00599         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_GAIN, &value)!=DC1394_SUCCESS){
00600                 g_error("Unable to get camera gain.");
00601                 return 0;
00602         }
00603         
00604         return value;
00605 }
00606 
00607 unsigned int WURDE1394Camera::getIris(){
00608         unsigned int value;
00609         
00610         if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_IRIS, &value)!=DC1394_SUCCESS){
00611                 g_error("Unable to get camera iris.");
00612                 return 0;
00613         }
00614         
00615         return value;
00616 }
00617 
00618 unsigned int WURDE1394Camera::getFocus(){
00619         unsigned int value;
00620         
00621        if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_FOCUS, &value)!=DC1394_SUCCESS){
00622               g_error("Unable to get camera focus.");
00623               return 0;
00624        }
00625 
00626        return value;
00627 }
00628 
00629 unsigned int WURDE1394Camera::getTriggerDelay(){
00630        unsigned int value;
00631 
00632        if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_TRIGGER_DELAY, &value)!=DC1394_SUCCESS){
00633               g_error("Unable to get camera trigger delay.");
00634               return 0;
00635        }
00636 
00637        return value;
00638 }
00639 
00640 unsigned int WURDE1394Camera::getZoom(){
00641        unsigned int value;
00642 
00643        if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_ZOOM, &value)!=DC1394_SUCCESS){
00644               g_error("Unable to get camera zoom.");
00645               return 0;
00646        }
00647 
00648        return value;
00649 }
00650 
00651 unsigned int WURDE1394Camera::getPan(){
00652        unsigned int value;
00653 
00654        if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_PAN, &value)!=DC1394_SUCCESS){
00655               g_error("Unable to get camera pan.");
00656               return 0;
00657        }
00658 
00659        return value;
00660 }
00661 
00662 unsigned int WURDE1394Camera::getTilt(){
00663        unsigned int value;
00664 
00665        if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_TILT, &value)!=DC1394_SUCCESS){
00666               g_error("Unable to get camera tilt.");
00667               return 0;
00668        }
00669 
00670        return value;
00671 }
00672 
00673 unsigned int WURDE1394Camera::getOpticalFilter(){
00674        unsigned int value;
00675 
00676        if(dc1394_feature_get_value(m_camera, DC1394_FEATURE_OPTICAL_FILTER, &value)!=DC1394_SUCCESS){
00677               g_error("Unable to get camera optical filter.");
00678               return 0;
00679        }
00680 
00681        return value;
00682 }
00683 
00684 
00685 /**********************/
00686 
00687 bool WURDE1394Camera::setBrightness(unsigned int value){
00688        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_BRIGHTNESS, value)!=DC1394_SUCCESS){
00689               g_error("Unable to set camera brightness.");
00690               return false;
00691        }
00692 
00693        return true;
00694 }
00695 
00696 bool WURDE1394Camera::setExposure(unsigned int value){
00697        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_EXPOSURE, value)!=DC1394_SUCCESS){
00698               g_error("Unable to set camera exposure.");
00699               return false;
00700        }
00701 
00702        return true;
00703 }
00704 bool WURDE1394Camera::setSharpness(unsigned int value){
00705        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_SHARPNESS, value)!=DC1394_SUCCESS){
00706               g_error("Unable to set camera sharpness.");
00707               return false;
00708        }
00709 
00710        return true;
00711 }
00712 
00713 bool WURDE1394Camera::setHue(unsigned int value){
00714        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_HUE, value)!=DC1394_SUCCESS){
00715               g_error("Unable to set camera hue.");
00716               return false;
00717        }
00718 
00719        return true;
00720 }
00721 
00722 bool WURDE1394Camera::setSaturation(unsigned int value){
00723        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_SATURATION, value)!=DC1394_SUCCESS){
00724               g_error("Unable to set camera saturation.");
00725               return false;
00726        }
00727 
00728        return true;
00729 }
00730 
00731 bool WURDE1394Camera::setGamma(unsigned int value){
00732        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_GAMMA, value)!=DC1394_SUCCESS){
00733               g_error("Unable to set camera gamma.");
00734               return false;
00735        }
00736 
00737        return true;
00738 }
00739 
00740 bool WURDE1394Camera::setShutter(unsigned int value){
00741        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_SHUTTER, value)!=DC1394_SUCCESS){
00742               g_error("Unable to set camera shutter.");
00743               return false;
00744        }
00745 
00746        return true;
00747 }
00748 
00749 bool WURDE1394Camera::setGain(unsigned int value){
00750        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_GAIN, value)!=DC1394_SUCCESS){
00751               g_error("Unable to set camera gain.");
00752               return false;
00753        }
00754 
00755        return true;
00756 }
00757 
00758 bool WURDE1394Camera::setIris(unsigned int value){
00759        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_IRIS, value)!=DC1394_SUCCESS){
00760               g_error("Unable to set camera iris.");
00761               return false;
00762        }
00763 
00764        return true;
00765 }
00766 
00767 bool WURDE1394Camera::setAutoIris(bool value){
00768        if(value){
00769               if(dc1394_feature_set_mode(m_camera, DC1394_FEATURE_IRIS, DC1394_FEATURE_MODE_AUTO)!=DC1394_SUCCESS){
00770                      g_error("Unable to set auto camera iris.");
00771                      return false;
00772               }
00773        }else{
00774               if(dc1394_feature_set_mode(m_camera, DC1394_FEATURE_IRIS, DC1394_FEATURE_MODE_MANUAL)!=DC1394_SUCCESS){
00775                      g_error("Unable to set auto camera iris.");
00776                      return false;
00777               }
00778        }
00779 
00780        return true;
00781 }
00782 
00783 bool WURDE1394Camera::setFocus(unsigned int value){
00784        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_FOCUS, value)!=DC1394_SUCCESS){
00785               g_error("Unable to set camera focus.");
00786               return false;
00787        }
00788 
00789        return true;
00790 }
00791 
00792 bool WURDE1394Camera::setTriggerDelay(unsigned int value){
00793        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_TRIGGER_DELAY, value)!=DC1394_SUCCESS){
00794               g_error("Unable to set camera trigger delay.");
00795               return false;
00796        }
00797 
00798        return true;
00799 }
00800 
00801 bool WURDE1394Camera::setZoom(unsigned int value){
00802        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_ZOOM, value)!=DC1394_SUCCESS){
00803               g_error("Unable to set camera zoom.");
00804               return false;
00805        }
00806 
00807        return true;
00808 }
00809 
00810 
00811 bool WURDE1394Camera::setPan(unsigned int value){
00812        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_PAN, value)!=DC1394_SUCCESS){
00813               g_error("Unable to set camera pan.");
00814               return false;
00815        }
00816 
00817        return true;
00818 }
00819 
00820 bool WURDE1394Camera::setTilt(unsigned int value){
00821        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_TILT, value)!=DC1394_SUCCESS){
00822               g_error("Unable to set camera tilt.");
00823               return false;
00824        }
00825 
00826        return true;
00827 }
00828 
00829 bool WURDE1394Camera::setOpticalFilter(unsigned int value){
00830        if(dc1394_feature_set_value(m_camera, DC1394_FEATURE_OPTICAL_FILTER, value)!=DC1394_SUCCESS){
00831               g_error("Unable to set camera optical filter.");
00832               return false;
00833        }
00834 
00835        return true;
00836 }

Generated on Thu Feb 1 15:31:54 2007 for WURDE by  doxygen 1.5.1