Update of /cvsroot/playerstage/code/player/server/drivers/camera/1394
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32041/server/drivers/camera/1394

Modified Files:
        camera1394.cc 
Log Message:
Apllied patches
[ 1874354 ] camera1394 fixes and Mac OS X support
[ 1875070 ] camera1394: allow setting of ISO speed

Index: camera1394.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/camera/1394/camera1394.cc,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** camera1394.cc       12 Dec 2007 19:15:59 -0000      1.37
--- camera1394.cc       28 Jan 2008 04:56:22 -0000      1.38
***************
*** 141,144 ****
--- 141,148 ----
    - Default: 4
    - the number of DMA buffers to use
+ 
+ - iso_speed (unsigned int)
+   - Default: 400
+   - Sets the data rate of the 1394 bus. Valid rates are 100, 200, 400, 800, 
1600, 3200.
  @par Example 
  
***************
*** 165,171 ****
  #include <stddef.h>       // for NULL
  #include <unistd.h>
! #include <libraw1394/raw1394.h>
  #if DC1394_DMA_SETUP_CAPTURE_ARGS == 20
  #include <dc1394/control.h>
  #else
  #include <libdc1394/dc1394_control.h>
--- 169,180 ----
  #include <stddef.h>       // for NULL
  #include <unistd.h>
! 
! #ifdef HAVE_LIBRAW1394
!     #include <libraw1394/raw1394.h>
! #endif
! 
  #if DC1394_DMA_SETUP_CAPTURE_ARGS == 20
  #include <dc1394/control.h>
+ #define LIBDC1394_VERSION  0200
  #else
  #include <libdc1394/dc1394_control.h>
***************
*** 180,185 ****
  
  
! // lots of defines are renames in v2 API, mask this so we dont ahve to modify 
all our code
! #if LIBDC1394_VERSION == 0200
  // Frame rate enum
  #define FRAMERATE_1_875 DC1394_FRAMERATE_1_875
--- 189,195 ----
  
  
! // lots of defines are renames in v2 API, mask this so we dont have to
! // modify all our code
! #if DC1394_DMA_SETUP_CAPTURE_ARGS == 20
  // Frame rate enum
  #define FRAMERATE_1_875 DC1394_FRAMERATE_1_875
***************
*** 257,267 ****
  #define         FEATURE_CAPTURE_QUALITY         DC1394_FEATURE_CAPTURE_QUALITY
  
  // speed enumerations
! #define DC1394_SPEED_100 DC1394_ISO_SPEED_100
! #define DC1394_SPEED_200 DC1394_ISO_SPEED_200,
! #define DC1394_SPEED_400 DC1394_ISO_SPEED_400,
! #define DC1394_SPEED_800 DC1394_ISO_SPEED_800,
! #define DC1394_SPEED_1600 DC1394_ISO_SPEED_1600,
! #define DC1394_SPEED_3200 DC1394_ISO_SPEED_3200
  
  #endif
--- 267,279 ----
  #define         FEATURE_CAPTURE_QUALITY         DC1394_FEATURE_CAPTURE_QUALITY
  
+ #else
+ 
  // speed enumerations
! #define DC1394_ISO_SPEED_100 SPEED_100
! #define DC1394_ISO_SPEED_200 SPEED_200
! #define DC1394_ISO_SPEED_400 SPEED_400
! #define DC1394_ISO_SPEED_800 SPEED_800
! #define DC1394_ISO_SPEED_1600 SPEED_1600
! #define DC1394_ISO_SPEED_3200 SPEED_3200
  
  #endif
***************
*** 289,293 ****
    private: int GrabFrame();
  
!   private: unsigned char * resized;//[1280 * 960 * 3];
  
    // Save a frame to disk
--- 301,305 ----
    private: int GrabFrame();
  
!   private: uint8_t * resized;//[1280 * 960 * 3];
  
    // Save a frame to disk
***************
*** 300,304 ****
--- 312,320 ----
    private: unsigned int port;
    private: unsigned int node;
+ 
+ #ifdef HAVE_LIBRAW1394
    private: raw1394handle_t handle;
+ #endif
+ 
  #if LIBDC1394_VERSION == 0200
    private: dc1394camera_t * camera;
***************
*** 322,329 ****
--- 338,347 ----
    private: unsigned int format;
    private: dc1394video_mode_t mode;
+   private: dc1394speed_t iso_speed;
  #else
    private: unsigned int frameRate;
    private: unsigned int format;
    private: unsigned int mode;
+   private: unsigned int iso_speed;
  #endif
  
***************
*** 383,387 ****
--- 401,407 ----
    resized=NULL;
  
+ #ifdef HAVE_LIBRAW1394
    this->handle = NULL;
+ #endif
    this->method = methodNone;
  
***************
*** 646,649 ****
--- 666,690 ----
    this->num_dma_buffers = cf->ReadInt(section, "dma_buffers", 
NUM_DMA_BUFFERS);
  
+   // ISO Speed?
+   switch(cf->ReadInt(section, "iso_speed", 400)) {
+     case 100:
+       this->iso_speed = DC1394_ISO_SPEED_100;
+       break;
+     case 200:
+       this->iso_speed = DC1394_ISO_SPEED_200;
+       break;
+     case 400:
+       this->iso_speed = DC1394_ISO_SPEED_400;
+       break;
+     case 800:
+       this->iso_speed = DC1394_ISO_SPEED_800;
+       break;
+     case 1600:
+       this->iso_speed = DC1394_ISO_SPEED_1600;
+       break;
+     case 3200:
+       this->iso_speed = DC1394_ISO_SPEED_3200;
+       break;
+   }
    this->data.compression = PLAYER_CAMERA_COMPRESS_RAW;
    
***************
*** 661,665 ****
    if (this->camera)
    {
!     dc1394_cleanup_iso_channels_and_bandwidth(camera);
      switch (this->method)
      {
--- 702,710 ----
    if (this->camera)
    {
!     //dc1394_cleanup_iso_channels_and_bandwidth(camera);
!     /* The above function has been removed from libdc1394 without a clear
!        replacement...
!       
http://sourceforge.net/mailarchive/message.php?msg_id=1196638611.10412.31.camel%40pisces.mit.edu
!     */
      switch (this->method)
      {
***************
*** 672,676 ****
        break;
      }
!     dc1394_free_camera(this->camera);
    }
    this->camera = NULL;
--- 717,721 ----
        break;
      }
!     dc1394_camera_free(this->camera);
    }
    this->camera = NULL;
***************
*** 698,701 ****
--- 743,748 ----
  int Camera1394::Setup()
  {
+   memset(&(this->data), 0, sizeof(this->data));
+ 
  #if LIBDC1394_VERSION == 0200
    dc1394speed_t speed;
***************
*** 709,738 ****
    // First we try to find a camera
    int err;
!   dc1394camera_t **dccameras=NULL;
!   unsigned int camnum=0;      
!   if ((err=dc1394_find_cameras(&dccameras,&camnum)) != DC1394_SUCCESS)
    {
      PLAYER_ERROR1("Could not get Camera List: %d\n", err);    
      return -1;
    }
!   if (camnum <=0)
      return -1;
  
    // we just use the first one returned and then free the rest
!   camera = dccameras[0];
! 
!   for (unsigned int i=1;i<camnum;i++)
!     free(dccameras[i]);
!   if (camnum>0)
!         free(dccameras);      
!   dc1394_cleanup_iso_channels_and_bandwidth(camera);
! 
!   if (this->camera == NULL)
    {
!     PLAYER_ERROR("Unable to acquire a dc1394 camera");
      this->SafeCleanup();
      return -1;
    }
  
  #else
    this->handle = dc1394_create_handle(this->port);
--- 756,792 ----
    // First we try to find a camera
    int err;
!   dc1394_t *d;
!   dc1394camera_list_t *list;
! 
!   d = dc1394_new ();
!   err = dc1394_camera_enumerate (d, &list);
!   if (err != DC1394_SUCCESS)
    {
      PLAYER_ERROR1("Could not get Camera List: %d\n", err);    
      return -1;
    }
! 
!   if (list->num == 0)
!   {
!     PLAYER_ERROR("No cameras found");
      return -1;
+   }
  
    // we just use the first one returned and then free the rest
!   camera = dc1394_camera_new (d, list->ids[0].guid);
!   
!   if (!camera)
    {
!     PLAYER_ERROR1("Failed to initialize camera with guid %llx",
!                   list->ids[0].guid);
      this->SafeCleanup();
      return -1;
    }
  
+   dc1394_camera_free_list (list);
+ 
+   //dc1394_cleanup_iso_channels_and_bandwidth(camera);
+   /* Above has been removed from API. */
+ 
  #else
    this->handle = dc1394_create_handle(this->port);
***************
*** 870,876 ****
    // stores them in features.
  #if LIBDC1394_VERSION == 0200
!   if (DC1394_SUCCESS != dc1394_get_camera_feature_set(camera, 
&this->features))
  #else
!   if (DC1394_SUCCESS != dc1394_get_camera_feature_set(this->handle, 
this->camera.node, 
                                                        &this->features))
  #endif
--- 924,931 ----
    // stores them in features.
  #if LIBDC1394_VERSION == 0200
!   if (DC1394_SUCCESS != dc1394_feature_get_all(camera, &this->features))
  #else
!   if (DC1394_SUCCESS != dc1394_get_camera_feature_set(this->handle,
!                                                       this->camera.node, 
                                                        &this->features))
  #endif
***************
*** 883,887 ****
    // TODO: need to indicate what formats the camera supports somewhere
    // Remove; leave?
-   dc1394_print_feature_set(&this->features);
  
  #if LIBDC1394_VERSION == 0200
--- 938,941 ----
***************
*** 925,929 ****
    if (!this->forceRaw &&
        dc1394_dma_setup_capture(this->handle, this->camera.node, channel,
!                                this->format, this->mode, speed,
                                 this->frameRate, this->num_dma_buffers, 1, 
NULL,
                                 &this->camera) == DC1394_SUCCESS)
--- 979,983 ----
    if (!this->forceRaw &&
        dc1394_dma_setup_capture(this->handle, this->camera.node, channel,
!                                this->format, this->mode, this->iso_speed,
                                 this->frameRate, this->num_dma_buffers, 1, 
NULL,
                                 &this->camera) == DC1394_SUCCESS)
***************
*** 932,936 ****
    if (!this->forceRaw &&
        dc1394_dma_setup_capture(this->handle, this->camera.node, channel,
!                                this->format, this->mode, speed,
                                 this->frameRate, this->num_dma_buffers, 1, 0, 
NULL,
                                 &this->camera) == DC1394_SUCCESS)
--- 986,990 ----
    if (!this->forceRaw &&
        dc1394_dma_setup_capture(this->handle, this->camera.node, channel,
!                                this->format, this->mode, this->iso_speed,
                                 this->frameRate, this->num_dma_buffers, 1, 0, 
NULL,
                                 &this->camera) == DC1394_SUCCESS)
***************
*** 946,950 ****
                DMA_Success = false;
        }
!       if (DC1394_SUCCESS != dc1394_video_set_iso_speed(camera,speed))
        {
                PLAYER_WARN("1394 failed to set iso speed");
--- 1000,1004 ----
                DMA_Success = false;
        }
!       if (DC1394_SUCCESS != 
dc1394_video_set_iso_speed(camera,this->iso_speed))
        {
                PLAYER_WARN("1394 failed to set iso speed");
***************
*** 1145,1153 ****
    unsigned int frame_width;
    unsigned int frame_height;
!   int * capture_buffer;
  #if LIBDC1394_VERSION == 0200
    frame_width = frame->size[0];
    frame_height = frame->size[1];
!   capture_buffer = (int *) frame->image;
  #else
    frame_width = this->camera.frame_width;
--- 1199,1207 ----
    unsigned int frame_width;
    unsigned int frame_height;
!   uint8_t * capture_buffer;
  #if LIBDC1394_VERSION == 0200
    frame_width = frame->size[0];
    frame_height = frame->size[1];
!   capture_buffer = (uint8_t *) frame->image;
  #else
    frame_width = this->camera.frame_width;
***************
*** 1159,1164 ****
      frameSize = frame_width * frame_height;
    
!   delete [] this->data.image;
!   this->data.image = NULL;
    switch (this->mode)
    {
--- 1213,1220 ----
      frameSize = frame_width * frame_height;
    
!   
!   //delete [] this->data.image;
!   //this->data.image = NULL;
!   int old_image_count = this->data.image_count;
    switch (this->mode)
    {
***************
*** 1168,1188 ****
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     this->data.image = new unsigned char [this->data.image_count];
      this->data.width = frame_width;
      this->data.height = frame_height;
!     uyvy2rgb((unsigned char *)capture_buffer, this->data.image, (frame_width) 
* (frame_height));
      break;
    case MODE_1024x768_YUV422:
    case MODE_1280x960_YUV422:
      if (resized == NULL)
!       resized = new unsigned char[1280 * 960 * 3];
      this->data.bpp = 24;
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     this->data.image = new unsigned char [this->data.image_count];
      this->data.width = frame_width / 2;
      this->data.height = frame_height / 2;
      assert(this->data.image_count <= sizeof(this->data.image));
!     uyvy2rgb((unsigned char *)capture_buffer, this->resized, (frame_width) * 
(frame_height));
      ptr1 = this->resized;
      ptr2 = this->data.image;
--- 1224,1246 ----
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
      this->data.width = frame_width;
      this->data.height = frame_height;
!     uyvy2rgb(capture_buffer, this->data.image, (frame_width) * 
(frame_height));
      break;
    case MODE_1024x768_YUV422:
    case MODE_1280x960_YUV422:
      if (resized == NULL)
!       resized = new uint8_t [1280 * 960 * 3];
      this->data.bpp = 24;
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
      this->data.width = frame_width / 2;
      this->data.height = frame_height / 2;
      assert(this->data.image_count <= sizeof(this->data.image));
!     uyvy2rgb(capture_buffer, this->resized, (frame_width) * (frame_height));
      ptr1 = this->resized;
      ptr2 = this->data.image;
***************
*** 1202,1213 ****
    case MODE_800x600_YUV422:
      if (resized == NULL)
!       resized = new unsigned char[1280 * 960 * 3];
      this->data.bpp = 24;
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     this->data.image = new unsigned char [this->data.image_count];
      this->data.width = 600;
      this->data.height = 450;
!     uyvy2rgb((unsigned char *)capture_buffer, this->resized, (frame_width) * 
(frame_height));
      ptr1 = this->resized;
      ptr2 = this->data.image;
--- 1260,1272 ----
    case MODE_800x600_YUV422:
      if (resized == NULL)
!       resized = new uint8_t [1280 * 960 * 3];
      this->data.bpp = 24;
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
      this->data.width = 600;
      this->data.height = 450;
!     uyvy2rgb(capture_buffer, this->resized, (frame_width) * (frame_height));
      ptr1 = this->resized;
      ptr2 = this->data.image;
***************
*** 1233,1240 ****
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     this->data.image = new unsigned char [this->data.image_count];
      this->data.width = frame_width;
      this->data.height = frame_height;
!     memcpy(this->data.image, (unsigned char *)capture_buffer, 
this->data.image_count);
      break;
    case MODE_640x480_MONO:
--- 1292,1300 ----
      this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
      this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
      this->data.width = frame_width;
      this->data.height = frame_height;
!     memcpy(this->data.image, capture_buffer, this->data.image_count);
      break;
    case MODE_640x480_MONO:
***************
*** 1248,1255 ****
        this->data.format = PLAYER_CAMERA_FORMAT_MONO8;
        this->data.image_count = this->frameSize;
!       this->data.image = new unsigned char [this->data.image_count];
        this->data.width = frame_width;
        this->data.height = frame_height;
!       memcpy(this->data.image, (unsigned char *)capture_buffer, 
this->data.image_count);
      } 
      else
--- 1308,1316 ----
        this->data.format = PLAYER_CAMERA_FORMAT_MONO8;
        this->data.image_count = this->frameSize;
!       if(old_image_count < this->data.image_count)
!           this->data.image = new uint8_t [this->data.image_count];
        this->data.width = frame_width;
        this->data.height = frame_height;
!       memcpy(this->data.image, capture_buffer, this->data.image_count);
      } 
      else
***************
*** 1263,1267 ****
          // quarter of the image but 3 bytes per pixel
        this->data.image_count = this->frameSize/4*3;
!       BayerDownsample((unsigned char *)capture_buffer, this->data.image,
                                        frame_width/2, frame_height/2,
                                        (bayer_pattern_t)this->BayerPattern);
--- 1324,1330 ----
          // quarter of the image but 3 bytes per pixel
        this->data.image_count = this->frameSize/4*3;
!         if(old_image_count < this->data.image_count)
!             this->data.image = new uint8_t [this->data.image_count];
!       BayerDownsample(capture_buffer, this->data.image,
                                        frame_width/2, frame_height/2,
                                        (bayer_pattern_t)this->BayerPattern);
***************
*** 1269,1273 ****
        case BAYER_DECODING_NEAREST:
          this->data.image_count = this->frameSize * 3;
!         BayerNearestNeighbor((unsigned char *)capture_buffer, dst,
                                        frame_width, frame_height,
                                        (bayer_pattern_t)this->BayerPattern);
--- 1332,1338 ----
        case BAYER_DECODING_NEAREST:
          this->data.image_count = this->frameSize * 3;
!         if(old_image_count < this->data.image_count)
!             this->data.image = new uint8_t [this->data.image_count];
!         BayerNearestNeighbor(capture_buffer, dst,
                                        frame_width, frame_height,
                                        (bayer_pattern_t)this->BayerPattern);
***************
*** 1275,1282 ****
        case BAYER_DECODING_EDGE_SENSE:
          this->data.image_count = this->frameSize * 3;
!         delete [] this->data.image;
!         this->data.image = new unsigned char [this->data.image_count];
          
!       BayerEdgeSense((unsigned char *)capture_buffer, dst,
                                        frame_width, frame_height,
                                        (bayer_pattern_t)this->BayerPattern);
--- 1340,1347 ----
        case BAYER_DECODING_EDGE_SENSE:
          this->data.image_count = this->frameSize * 3;
!         if(old_image_count < this->data.image_count)
!             this->data.image = new uint8_t [this->data.image_count];
          
!       BayerEdgeSense(capture_buffer, dst,
                                        frame_width, frame_height,
                                        (bayer_pattern_t)this->BayerPattern);


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to