Changeset 346 in flair-src for trunk/lib/FlairSensorActuator


Ignore:
Timestamp:
Feb 10, 2020, 5:18:14 PM (5 years ago)
Author:
Sanahuja Guillaume
Message:

v4l modifs, image ok sur gcs

Location:
trunk/lib/FlairSensorActuator/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/V4LCamera.cpp

    r340 r346  
    3333#define DEFAULT_V4L_BUFFERS 4
    3434
    35 #define CHANNEL_NUMBER 1
    3635#define CLEAR(x) memset (&(x), 0, sizeof (x))
    3736#define DEFAULT_V4L_WIDTH  640
    3837#define DEFAULT_V4L_HEIGHT 480
    39 #define CV_CAP_PROP_POS_MSEC       0
    40 #define CV_CAP_PROP_POS_FRAMES     1
    41 #define CV_CAP_PROP_POS_AVI_RATIO  2
    42 #define CV_CAP_PROP_FRAME_WIDTH    3
    43 #define CV_CAP_PROP_FRAME_HEIGHT   4
    44 #define CV_CAP_PROP_FPS            5
    45 #define CV_CAP_PROP_FOURCC         6
    46 #define CV_CAP_PROP_FRAME_COUNT    7
     38//#define CV_CAP_PROP_POS_MSEC       0
     39//#define CV_CAP_PROP_POS_FRAMES     1
     40//#define CV_CAP_PROP_POS_AVI_RATIO  2
     41//#define CV_CAP_PROP_FRAME_WIDTH    3
     42//#define CV_CAP_PROP_FRAME_HEIGHT   4
     43//#define CV_CAP_PROP_FPS            5
     44//#define CV_CAP_PROP_FOURCC         6
     45//#define CV_CAP_PROP_FRAME_COUNT    7
    4746#define CV_CAP_PROP_FORMAT         8
    4847#define CV_CAP_PROP_MODE           9
     
    5251#define CV_CAP_PROP_HUE           13
    5352#define CV_CAP_PROP_GAIN          14
    54 #define CV_CAP_PROP_CONVERT_RGB   15
     53//#define CV_CAP_PROP_CONVERT_RGB   15
    5554#define CV_CAP_PROP_SHARPNESS     16
    5655#define CV_CAP_PROP_EXPOSURE      17
     
    5857#define CV_CAP_PROP_AWB           19
    5958
    60 #define HAVE_CAMV4L2
    61 
    6259using std::string;
    6360using namespace flair::core;
     
    6764namespace sensor {
    6865 
    69   V4LCamera::V4LCamera(string name,
    70                      uint8_t camera_index, uint16_t width, uint16_t height,
     66V4LCamera::V4LCamera(string name,uint8_t camera_index, uint16_t width, uint16_t height,
    7167                     Image::Type::Format format, uint8_t priority)
    7268    : Thread(getFrameworkManager(), name, priority),
    7369      Camera(name, width, height, format) {
    7470 
    75     string deviceName="/dev/video"+std::to_string(camera_index);
    76     device = open(deviceName.c_str(), O_RDWR | O_NONBLOCK);
    77     if (device == -1) {
    78         Thread::Err("Cannot open %s\n",deviceName.c_str());
    79     } else {
    80         Printf("V4LCamera %s, opened %s\n",name.c_str(),deviceName.c_str());
    81     }
    82 
    83     /* w/o memset some parts  arent initialized - AKA: Fill it with zeros so it is clean */
    84    memset(&capture,0,sizeof(CvCaptureCAM_V4L));
    85    /* Present the routines needed for V4L funtionality.  They are inserted as part of
    86       the standard set of cv calls promoting transparency.  "Vector Table" insertion. */
    87    capture.FirstCapture = 1;
    88    capture.deviceHandle = device;
    89  
    90      PALETTE_YUYV = 0;
    91      PALETTE_UYVY= 0;
    92    
    93    n_buffers = 0;
    94    if (_capture_V4L2 (&capture) == -1) {
    95      Thread::Err("_capture_V4L2 failed\n");
    96    }
    97  
    98 if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FRAME_WIDTH, width)<0)
    99     Thread::Err("cvSetCaptureProperty error\n");
    100   if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FRAME_HEIGHT, height)<0)
    101     Thread::Err("cvSetCaptureProperty error\n");
    102 
    103   if (format == Image::Type::Format::UYVY) {
    104     if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY)<0)
    105       Thread::Err("cvSetCaptureProperty error\n");
     71  string deviceName="/dev/video"+std::to_string(camera_index);
     72  device = open(deviceName.c_str(), O_RDWR | O_NONBLOCK);
     73  if (device == -1) {
     74      Thread::Err("Cannot open %s\n",deviceName.c_str());
     75  } else {
     76      Printf("V4LCamera %s, opened %s\n",name.c_str(),deviceName.c_str());
     77  }
     78
     79  /* w/o memset some parts  arent initialized - AKA: Fill it with zeros so it is clean */
     80  memset(&capture,0,sizeof(CvCaptureCAM_V4L));
     81  capture.FirstCapture = 1;
     82  PALETTE_YUYV = 0;
     83  PALETTE_UYVY= 0;
     84  n_buffers = 0;
     85 
     86  if(init(width,height) == -1) {
     87   Thread::Err("initialisation failed\n");
     88  }
     89 
     90  if(format == Image::Type::Format::UYVY) {
     91    if (setV4LProperty(CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY)<0)
     92      Thread::Err("set capture property error\n");
    10693  } else if (format == Image::Type::Format::YUYV) {
    107     if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_YUYV) <
     94    if (setV4LProperty(CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_YUYV) <
    10895        0)
    109       Thread::Err("cvSetCaptureProperty error\n");
     96      Thread::Err("set capture property error\n");
    11097  } else {
    11198    Thread::Err("format not supported\n");
    11299  }
    113     // ground station
    114     gain = new DoubleSpinBox(GetGroupBox()->NewRow(), "gain:", 0, 1, 0.1);
    115     exposure = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "exposure:", 0,1, 0.1);
    116     bright = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "bright:", 0, 1, 0.1);
    117     contrast = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "contrast:", 0,1, 0.1);
    118     hue = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "hue:", 0, 1, 0.1);
    119     sharpness = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "sharpness:", 0, 1, 0.1);
    120     sat = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "saturation:", 0, 1,0.1);
    121     autogain = new CheckBox(GetGroupBox()->NewRow(), "autogain:");
    122     autoexposure = new CheckBox(GetGroupBox()->LastRowLastCol(), "autoexposure:");
    123     awb = new CheckBox(GetGroupBox()->LastRowLastCol(), "awb:");
    124     fps = new Label(GetGroupBox()->NewRow(), "fps");
    125 
    126     hasProblems=false;
     100 
     101  // ground station
     102  gain = new DoubleSpinBox(GetGroupBox()->NewRow(), "gain:", 0, 1, 0.1);
     103  exposure = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "exposure:", 0,1, 0.1);
     104  bright = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "bright:", 0, 1, 0.1);
     105  contrast = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "contrast:", 0,1, 0.1);
     106  hue = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "hue:", 0, 1, 0.1);
     107  sharpness = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "sharpness:", 0, 1, 0.1);
     108  sat = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "saturation:", 0, 1,0.1);
     109  autogain = new CheckBox(GetGroupBox()->NewRow(), "autogain:");
     110  autoexposure = new CheckBox(GetGroupBox()->LastRowLastCol(), "autoexposure:");
     111  awb = new CheckBox(GetGroupBox()->LastRowLastCol(), "awb:");
     112  fps = new Label(GetGroupBox()->NewRow(), "fps");
     113
     114  hasProblems=false;
    127115}
    128116
    129117V4LCamera::~V4LCamera() {
    130     for (int n_buffers = 0; n_buffers < nbBuffers; n_buffers++) {
     118  for (int n_buffers = 0; n_buffers < nbBuffers; n_buffers++) {
    131119       //FreeFunction((char*)buffers[n_buffers].start);
    132    }
    133     SafeStop();
    134     Join();
    135 }
    136 int V4LCamera::icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
    137                                   int property_id, double value ){
    138     static int width = 0, height = 0;
    139     int retval;
    140 
    141     /* initialization */
    142     retval = 0;
    143 
    144     /* two subsequent calls setting WIDTH and HEIGHT will change
    145        the video size */
    146     /* the first one will return an error, though. */
    147 
    148     switch (property_id) {
    149     case CV_CAP_PROP_FRAME_WIDTH:
    150         width = value;
    151         if(width !=0 && height != 0) {
    152             retval = icvSetVideoSize( capture, width, height);
    153             width = height = 0;
    154         }
    155         break;
    156     case CV_CAP_PROP_FRAME_HEIGHT:
    157         height = value;
    158         if(width !=0 && height != 0) {
    159             retval = icvSetVideoSize( capture, width, height);
    160             width = height = 0;
    161         }
    162         break;
     120  }
     121  SafeStop();
     122  Join();
     123}
     124
     125int V4LCamera::init(int width, int height) {
     126  CLEAR (capture.cap);
     127  if(-1 == xioctl(device, VIDIOC_QUERYCAP, &capture.cap)) {
     128    return -1;
     129  } else {
     130    CLEAR (capture.capability);
     131    capture.capability.type = capture.cap.capabilities;
     132
     133    /* Query channels number */
     134    if (-1 == xioctl(device, VIDIOC_G_INPUT, &capture.capability.channels)) {
     135      return -1;
     136    }
     137  }
     138
     139  /* Init V4L2 control variables */
     140  capture.v4l2_brightness = 0;
     141  capture.v4l2_contrast = 0;
     142  capture.v4l2_saturation = 0;
     143  capture.v4l2_hue = 0;
     144  capture.v4l2_gain = 0;
     145  capture.v4l2_sharpness = 0;
     146  capture.v4l2_exposure = 0;
     147  capture.v4l2_autogain = 0;
     148  capture.v4l2_awb = 0;
     149
     150  capture.v4l2_brightness_min = 0;
     151  capture.v4l2_contrast_min = 0;
     152  capture.v4l2_saturation_min = 0;
     153  capture.v4l2_hue_min = 0;
     154  capture.v4l2_gain_min = 0;
     155  capture.v4l2_sharpness_min = 0;
     156  capture.v4l2_exposure_min = 0;
     157  capture.v4l2_autogain_min = 0;
     158  capture.v4l2_awb_min = 0;
     159
     160  capture.v4l2_brightness_max = 0;
     161  capture.v4l2_contrast_max = 0;
     162  capture.v4l2_saturation_max = 0;
     163  capture.v4l2_hue_max = 0;
     164  capture.v4l2_gain_max = 0;
     165  capture.v4l2_sharpness_max = 0;
     166  capture.v4l2_exposure_max = 0;
     167  capture.v4l2_autogain_max = 0;
     168  capture.v4l2_awb_max = 0;
     169     
     170  if ((capture.cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
     171    Thread::Err("device is unable to capture video memory.\n");
     172    return -1;
     173  }
     174
     175  /* Find Window info */
     176  CLEAR (capture.form);
     177  capture.form.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
     178     
     179  if (-1 == xioctl (device, VIDIOC_G_FMT, &capture.form)) {
     180     Thread::Err("Could not obtain specifics of capture window.\n");
     181     return -1;
     182  }
     183
     184  if (autosetup_capture_mode_v4l2(&capture) == -1) {
     185     return -1;
     186  }
     187
     188  icvSetVideoSize(&capture, width, height);
     189
     190  unsigned int min;
     191
     192  /* Buggy driver paranoia. */
     193  min = capture.form.fmt.pix.width * 2;
     194  if (capture.form.fmt.pix.bytesperline < min) {
     195   capture.form.fmt.pix.bytesperline = min;
     196  }
     197
     198  min = capture.form.fmt.pix.bytesperline * capture.form.fmt.pix.height;
     199  if (capture.form.fmt.pix.sizeimage < min) {
     200   capture.form.fmt.pix.sizeimage = min;
     201  }
     202
     203  return 1;
     204}
     205
     206int V4LCamera::setV4LProperty(int property_id, double value){
     207  int retval=0;
     208  switch (property_id) {
    163209    case CV_CAP_PROP_FORMAT:
    164 
    165         capture->form.fmt.pix.pixelformat = (unsigned long)value;
    166         retval == xioctl (capture->deviceHandle, VIDIOC_S_FMT, &capture->form);
    167         if ((unsigned long)value != capture->form.fmt.pix.pixelformat)
    168                 retval=-1;
    169 
    170        
    171         PALETTE_YUYV = 0;
    172         PALETTE_UYVY= 0;
    173        
    174 
    175         if ((unsigned long)value== V4L2_PIX_FMT_YUYV)
    176         {
    177                 PALETTE_YUYV = 1;
    178         }
    179         if ((unsigned long)value== V4L2_PIX_FMT_UYVY)
    180         {
    181                 PALETTE_UYVY = 1;
    182         }
    183        
    184 
    185         break;
    186     case CV_CAP_PROP_BRIGHTNESS:
    187     case CV_CAP_PROP_CONTRAST:
    188     case CV_CAP_PROP_SATURATION:
    189     case CV_CAP_PROP_HUE:
    190     case CV_CAP_PROP_GAIN:
    191     case CV_CAP_PROP_SHARPNESS:
    192     case CV_CAP_PROP_EXPOSURE:
    193     case CV_CAP_PROP_AUTOGAIN:
    194     case CV_CAP_PROP_AWB:
    195         retval = icvSetControl(capture, property_id, value);
    196         break;
     210      capture.form.fmt.pix.pixelformat = (unsigned long)value;
     211      retval == xioctl(device, VIDIOC_S_FMT, &capture.form);
     212      if ((unsigned long)value != capture.form.fmt.pix.pixelformat) {
     213        retval=-1;
     214      }
     215      PALETTE_YUYV = 0;
     216      PALETTE_UYVY= 0;
     217      if((unsigned long)value== V4L2_PIX_FMT_YUYV) {
     218        PALETTE_YUYV = 1;
     219      }
     220      if((unsigned long)value== V4L2_PIX_FMT_UYVY) {
     221        PALETTE_UYVY = 1;
     222      }
     223      break;
    197224    default:
    198         fprintf(stderr,
    199                 "HIGHGUI ERROR: V4L: setting property #%d is not supported\n",
    200                 property_id);
    201     }
    202 
    203     /* return the the status */
    204     return retval;
    205 }
    206 int V4LCamera::icvSetControl (CvCaptureCAM_V4L* capture,
    207                           int property_id, double value) {
     225      Thread::Warn("setting property #%d is not supported\n",property_id);
     226  }
     227
     228  return retval;
     229}
     230
     231int V4LCamera::icvSetControl(CvCaptureCAM_V4L* capture,int property_id, double value) {
    208232 
    209233  /* limitation of the input value */
     
    260284
    261285    /* get the min and max values */
    262     if (-1 == xioctl (capture->deviceHandle,
    263                       VIDIOC_G_CTRL, &capture->control)) {
     286    if (-1 == xioctl (device,VIDIOC_G_CTRL, &capture->control)) {
    264287//          perror ("VIDIOC_G_CTRL for getting min/max values");
    265288          return -1;
     
    351374
    352375    /* The driver may clamp the value or return ERANGE, ignored here */
    353     if (-1 == xioctl (capture->deviceHandle,
    354                       VIDIOC_S_CTRL, &capture->control) && errno != ERANGE) {
     376    if (-1 == xioctl (device,VIDIOC_S_CTRL, &capture->control) && errno != ERANGE) {
    355377        perror ("VIDIOC_S_CTRL");
    356378        return -1;
     
    361383
    362384}
    363 int V4LCamera::_capture_V4L2 (CvCaptureCAM_V4L *capture)
    364 {
    365    int detect_v4l2 = 0;
    366 
    367    detect_v4l2 = try_init_v4l2(capture);
    368 
    369    if (detect_v4l2 != 1) {
    370        /* init of the v4l2 device is not OK */
    371        return -1;
    372    }
    373 
    374    /* Init V4L2 control variables */
    375    capture->v4l2_brightness = 0;
    376    capture->v4l2_contrast = 0;
    377    capture->v4l2_saturation = 0;
    378    capture->v4l2_hue = 0;
    379    capture->v4l2_gain = 0;
    380    capture->v4l2_sharpness = 0;
    381    capture->v4l2_exposure = 0;
    382    capture->v4l2_autogain = 0;
    383    capture->v4l2_awb = 0;
    384 
    385    capture->v4l2_brightness_min = 0;
    386    capture->v4l2_contrast_min = 0;
    387    capture->v4l2_saturation_min = 0;
    388    capture->v4l2_hue_min = 0;
    389    capture->v4l2_gain_min = 0;
    390    capture->v4l2_sharpness_min = 0;
    391    capture->v4l2_exposure_min = 0;
    392    capture->v4l2_autogain_min = 0;
    393    capture->v4l2_awb_min = 0;
    394 
    395    capture->v4l2_brightness_max = 0;
    396    capture->v4l2_contrast_max = 0;
    397    capture->v4l2_saturation_max = 0;
    398    capture->v4l2_hue_max = 0;
    399    capture->v4l2_gain_max = 0;
    400    capture->v4l2_sharpness_max = 0;
    401    capture->v4l2_exposure_max = 0;
    402    capture->v4l2_autogain_max = 0;
    403    capture->v4l2_awb_max = 0;
    404      
    405  
    406    if ((capture->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
    407       /* Nope. */
    408       fprintf( stderr, "HIGHGUI ERROR: V4L2: device is unable to capture video memory.\n");
    409      
    410       return -1;
    411    }
    412 
    413  
    414 
    415    /* Find Window info */
    416    CLEAR (capture->form);
    417    capture->form.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    418        
    419    if (-1 == xioctl (capture->deviceHandle, VIDIOC_G_FMT, &capture->form)) {
    420        fprintf( stderr, "HIGHGUI ERROR: V4L2: Could not obtain specifics of capture window.\n\n");
    421        
    422        return -1;
    423    }
    424 
    425  
    426 
    427    if (autosetup_capture_mode_v4l2(capture) == -1)
    428        return -1;
    429 
    430    icvSetVideoSize(capture, DEFAULT_V4L_WIDTH, DEFAULT_V4L_HEIGHT);
    431 
    432    unsigned int min;
    433 
    434    /* Buggy driver paranoia. */
    435    min = capture->form.fmt.pix.width * 2;
    436 
    437    if (capture->form.fmt.pix.bytesperline < min)
    438        capture->form.fmt.pix.bytesperline = min;
    439 
    440    min = capture->form.fmt.pix.bytesperline * capture->form.fmt.pix.height;
    441  
    442    if (capture->form.fmt.pix.sizeimage < min)
    443        capture->form.fmt.pix.sizeimage = min;
    444 
    445    return 1;
    446 }
     385
     386
    447387int V4LCamera::icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h) {
    448388
     
    457397
    458398    /* set the crop area, but don't exit if the device don't support croping */
    459     xioctl (capture->deviceHandle, VIDIOC_S_CROP, &capture->crop);
     399    xioctl (device, VIDIOC_S_CROP, &capture->crop);
    460400
    461401    CLEAR (capture->form);
     
    463403
    464404    /* read the current setting, mainly to retreive the pixelformat information */
    465     xioctl (capture->deviceHandle, VIDIOC_G_FMT, &capture->form);
     405    xioctl (device, VIDIOC_G_FMT, &capture->form);
    466406
    467407    /* set the values we want to change */
     
    478418     * don't allow changing the size, and we will get the real size
    479419     * later */
    480     xioctl (capture->deviceHandle, VIDIOC_S_FMT, &capture->form);
     420    xioctl (device, VIDIOC_S_FMT, &capture->form);
    481421
    482422    /* try to set framerate to 30 fps */
     
    486426    setfps.parm.capture.timeperframe.numerator = 1;
    487427    setfps.parm.capture.timeperframe.denominator = 30;
    488     xioctl (capture->deviceHandle, VIDIOC_S_PARM, &setfps);
     428    xioctl (device, VIDIOC_S_PARM, &setfps);
    489429
    490430    /* we need to re-initialize some things, like buffers, because the size has
     
    493433
    494434    /* Get window info again, to get the real value */
    495     if (-1 == xioctl (capture->deviceHandle, VIDIOC_G_FMT, &capture->form))
     435    if (-1 == xioctl (device, VIDIOC_G_FMT, &capture->form))
    496436    {
    497437      fprintf(stderr, "HIGHGUI ERROR: V4L/V4L2: Could not obtain specifics of capture window.\n\n");
     
    520460  capture->form.fmt.pix.height = DEFAULT_V4L_HEIGHT;
    521461 
    522   if (-1 == xioctl (capture->deviceHandle, VIDIOC_S_FMT, &capture->form))
     462  if (-1 == xioctl (device, VIDIOC_S_FMT, &capture->form))
    523463      return -1;
    524464
     
    545485}
    546486
    547 
    548 
    549 int V4LCamera::try_init_v4l2(CvCaptureCAM_V4L* capture)
    550 {
    551 
    552   // if detect = -1 then unable to open device
    553   // if detect = 0 then detected nothing
    554   // if detect = 1 then V4L2 device
    555   int detect = 0;
    556 
    557 
    558   if (detect == 0)
    559   {
    560     CLEAR (capture->cap);
    561     if (-1 == xioctl (capture->deviceHandle, VIDIOC_QUERYCAP, &capture->cap))
    562     {
    563       detect = 0;
    564 
    565      
    566     }
    567       else
    568     {
    569       CLEAR (capture->capability);
    570       capture->capability.type = capture->cap.capabilities;
    571      
    572       /* Query channels number */
    573       if (-1 != xioctl (capture->deviceHandle, VIDIOC_G_INPUT, &capture->capability.channels))
    574       {
    575         detect = 1;
    576       }
    577     }
    578   }
    579 
    580   return detect;
    581 
    582 }
    583487/*
    584488V4LCamera::V4LCamera(string name,
     
    776680   capture->req.memory = V4L2_MEMORY_MMAP;
    777681
    778    if (-1 == xioctl (capture->deviceHandle, VIDIOC_REQBUFS, &capture->req))
     682   if (-1 == xioctl (device, VIDIOC_REQBUFS, &capture->req))
    779683   {
    780684       if (EINVAL == errno)
     
    816720       buf.index = n_buffers;
    817721
    818        if (-1 == xioctl (capture->deviceHandle, VIDIOC_QUERYBUF, &buf)) {
     722       if (-1 == xioctl (device, VIDIOC_QUERYBUF, &buf)) {
    819723           perror ("VIDIOC_QUERYBUF");
    820724       
     
    830734               PROT_READ | PROT_WRITE /* required */,
    831735               MAP_SHARED /* recommended */,
    832                capture->deviceHandle, buf.m.offset);
     736               device, buf.m.offset);
    833737
    834738       if (MAP_FAILED == capture->buffers[n_buffers].start) {
     
    880784          buf.index       = (unsigned long)capture->bufferIndex;
    881785
    882           if (-1 == xioctl (capture->deviceHandle, VIDIOC_QBUF, &buf)) {
     786          if (-1 == xioctl (device, VIDIOC_QBUF, &buf)) {
    883787              perror ("VIDIOC_QBUF");
    884788              return 0;
     
    888792        /* enable the streaming */
    889793        capture->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    890         if (-1 == xioctl (capture->deviceHandle, VIDIOC_STREAMON,
     794        if (-1 == xioctl (device, VIDIOC_STREAMON,
    891795                          &capture->type)) {
    892796            /* error enabling the stream */
     
    922826
    923827            FD_ZERO (&fds);
    924             FD_SET (capture->deviceHandle, &fds);
     828            FD_SET (device, &fds);
    925829
    926830            /* Timeout. */
     
    928832            tv.tv_usec = 0;
    929833
    930             r = select (capture->deviceHandle+1, &fds, NULL, NULL, &tv);
     834            r = select (device+1, &fds, NULL, NULL, &tv);
    931835
    932836            if (-1 == r) {
     
    957861    buf.memory = V4L2_MEMORY_MMAP;
    958862
    959     if (-1 == xioctl (capture->deviceHandle, VIDIOC_DQBUF, &buf)) {
     863    if (-1 == xioctl (device, VIDIOC_DQBUF, &buf)) {
    960864        switch (errno) {
    961865        case EAGAIN:
     
    982886
    983887
    984    if (-1 == xioctl (capture->deviceHandle, VIDIOC_QBUF, &buf))
     888   if (-1 == xioctl (device, VIDIOC_QBUF, &buf))
    985889       perror ("VIDIOC_QBUF");
    986890
  • trunk/lib/FlairSensorActuator/src/V4LCamera.h

    r340 r346  
    2222
    2323namespace flair {
    24 namespace core {
    25 class Image;
    26 }
    27 namespace gui {
    28 class DoubleSpinBox;
    29 class CheckBox;
    30 class Label;
    31 }
     24  namespace core {
     25    class Image;
     26  }
     27  namespace gui {
     28    class DoubleSpinBox;
     29    class CheckBox;
     30    class Label;
     31  }
    3232}
    3333
     
    166166    typedef struct CvCaptureCAM_V4L
    167167{
    168     int deviceHandle;
     168    //int deviceHandle;
    169169    int bufferIndex;
    170170    int FirstCapture;
     
    209209
    210210CvCaptureCAM_V4L capture;
    211 int _capture_V4L2 (CvCaptureCAM_V4L *capture);
    212 int try_init_v4l2(CvCaptureCAM_V4L* capture);
     211int init(int width, int height);
    213212int autosetup_capture_mode_v4l2(CvCaptureCAM_V4L* capture);
    214213int icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h);
    215214int try_palette_v4l2(CvCaptureCAM_V4L* capture, unsigned long colorspace);
    216215int  PALETTE_YUYV,PALETTE_UYVY;
    217 int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,int property_id, double value );
     216int setV4LProperty(int property_id, double value );
    218217int icvSetControl (CvCaptureCAM_V4L* capture,int property_id, double value) ;
    219218int cvGrabFrame(CvCaptureCAM_V4L* capture);
Note: See TracChangeset for help on using the changeset viewer.