/home/fwph/code/wurde/rde/utils/1394Camera.cpp

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

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