Index: /trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 345)
+++ /trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 346)
@@ -33,16 +33,15 @@
 #define DEFAULT_V4L_BUFFERS 4
 
-#define CHANNEL_NUMBER 1
 #define CLEAR(x) memset (&(x), 0, sizeof (x))
 #define DEFAULT_V4L_WIDTH  640
 #define DEFAULT_V4L_HEIGHT 480
-#define CV_CAP_PROP_POS_MSEC       0
-#define CV_CAP_PROP_POS_FRAMES     1
-#define CV_CAP_PROP_POS_AVI_RATIO  2
-#define CV_CAP_PROP_FRAME_WIDTH    3
-#define CV_CAP_PROP_FRAME_HEIGHT   4
-#define CV_CAP_PROP_FPS            5
-#define CV_CAP_PROP_FOURCC         6
-#define CV_CAP_PROP_FRAME_COUNT    7
+//#define CV_CAP_PROP_POS_MSEC       0
+//#define CV_CAP_PROP_POS_FRAMES     1
+//#define CV_CAP_PROP_POS_AVI_RATIO  2
+//#define CV_CAP_PROP_FRAME_WIDTH    3
+//#define CV_CAP_PROP_FRAME_HEIGHT   4
+//#define CV_CAP_PROP_FPS            5
+//#define CV_CAP_PROP_FOURCC         6
+//#define CV_CAP_PROP_FRAME_COUNT    7
 #define CV_CAP_PROP_FORMAT         8
 #define CV_CAP_PROP_MODE           9
@@ -52,5 +51,5 @@
 #define CV_CAP_PROP_HUE           13
 #define CV_CAP_PROP_GAIN          14
-#define CV_CAP_PROP_CONVERT_RGB   15
+//#define CV_CAP_PROP_CONVERT_RGB   15
 #define CV_CAP_PROP_SHARPNESS     16
 #define CV_CAP_PROP_EXPOSURE      17
@@ -58,6 +57,4 @@
 #define CV_CAP_PROP_AWB           19
 
-#define HAVE_CAMV4L2
-
 using std::string;
 using namespace flair::core;
@@ -67,143 +64,170 @@
 namespace sensor {
   
-  V4LCamera::V4LCamera(string name,
-                     uint8_t camera_index, uint16_t width, uint16_t height,
+V4LCamera::V4LCamera(string name,uint8_t camera_index, uint16_t width, uint16_t height,
                      Image::Type::Format format, uint8_t priority)
     : Thread(getFrameworkManager(), name, priority),
       Camera(name, width, height, format) {
   
-    string deviceName="/dev/video"+std::to_string(camera_index);
-    device = open(deviceName.c_str(), O_RDWR | O_NONBLOCK);
-    if (device == -1) {
-        Thread::Err("Cannot open %s\n",deviceName.c_str());
-    } else {
-        Printf("V4LCamera %s, opened %s\n",name.c_str(),deviceName.c_str());
-    }
-
-    /* w/o memset some parts  arent initialized - AKA: Fill it with zeros so it is clean */
-   memset(&capture,0,sizeof(CvCaptureCAM_V4L));
-   /* Present the routines needed for V4L funtionality.  They are inserted as part of
-      the standard set of cv calls promoting transparency.  "Vector Table" insertion. */
-   capture.FirstCapture = 1;
-   capture.deviceHandle = device;
-  
-     PALETTE_YUYV = 0;
-     PALETTE_UYVY= 0;
-    
-   n_buffers = 0;
-   if (_capture_V4L2 (&capture) == -1) {
-     Thread::Err("_capture_V4L2 failed\n");
-   }
-  
-if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FRAME_WIDTH, width)<0)
-    Thread::Err("cvSetCaptureProperty error\n");
-  if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FRAME_HEIGHT, height)<0)
-    Thread::Err("cvSetCaptureProperty error\n");
-
-  if (format == Image::Type::Format::UYVY) {
-    if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY)<0)
-      Thread::Err("cvSetCaptureProperty error\n");
+  string deviceName="/dev/video"+std::to_string(camera_index);
+  device = open(deviceName.c_str(), O_RDWR | O_NONBLOCK);
+  if (device == -1) {
+      Thread::Err("Cannot open %s\n",deviceName.c_str());
+  } else {
+      Printf("V4LCamera %s, opened %s\n",name.c_str(),deviceName.c_str());
+  }
+
+  /* w/o memset some parts  arent initialized - AKA: Fill it with zeros so it is clean */
+  memset(&capture,0,sizeof(CvCaptureCAM_V4L));
+  capture.FirstCapture = 1;
+  PALETTE_YUYV = 0;
+  PALETTE_UYVY= 0;
+  n_buffers = 0;
+  
+  if(init(width,height) == -1) {
+   Thread::Err("initialisation failed\n");
+  }
+  
+  if(format == Image::Type::Format::UYVY) {
+    if (setV4LProperty(CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY)<0)
+      Thread::Err("set capture property error\n");
   } else if (format == Image::Type::Format::YUYV) {
-    if (icvSetPropertyCAM_V4L(&capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_YUYV) <
+    if (setV4LProperty(CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_YUYV) <
         0)
-      Thread::Err("cvSetCaptureProperty error\n");
+      Thread::Err("set capture property error\n");
   } else {
     Thread::Err("format not supported\n");
   }
-    // ground station
-    gain = new DoubleSpinBox(GetGroupBox()->NewRow(), "gain:", 0, 1, 0.1);
-    exposure = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "exposure:", 0,1, 0.1);
-    bright = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "bright:", 0, 1, 0.1);
-    contrast = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "contrast:", 0,1, 0.1);
-    hue = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "hue:", 0, 1, 0.1);
-    sharpness = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "sharpness:", 0, 1, 0.1);
-    sat = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "saturation:", 0, 1,0.1);
-    autogain = new CheckBox(GetGroupBox()->NewRow(), "autogain:");
-    autoexposure = new CheckBox(GetGroupBox()->LastRowLastCol(), "autoexposure:");
-    awb = new CheckBox(GetGroupBox()->LastRowLastCol(), "awb:");
-    fps = new Label(GetGroupBox()->NewRow(), "fps");
-
-    hasProblems=false;
+  
+  // ground station
+  gain = new DoubleSpinBox(GetGroupBox()->NewRow(), "gain:", 0, 1, 0.1);
+  exposure = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "exposure:", 0,1, 0.1);
+  bright = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "bright:", 0, 1, 0.1);
+  contrast = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "contrast:", 0,1, 0.1);
+  hue = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "hue:", 0, 1, 0.1);
+  sharpness = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "sharpness:", 0, 1, 0.1);
+  sat = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "saturation:", 0, 1,0.1);
+  autogain = new CheckBox(GetGroupBox()->NewRow(), "autogain:");
+  autoexposure = new CheckBox(GetGroupBox()->LastRowLastCol(), "autoexposure:");
+  awb = new CheckBox(GetGroupBox()->LastRowLastCol(), "awb:");
+  fps = new Label(GetGroupBox()->NewRow(), "fps");
+
+  hasProblems=false;
 }
 
 V4LCamera::~V4LCamera() {
-    for (int n_buffers = 0; n_buffers < nbBuffers; n_buffers++) {
+  for (int n_buffers = 0; n_buffers < nbBuffers; n_buffers++) {
        //FreeFunction((char*)buffers[n_buffers].start);
-   }
-    SafeStop();
-    Join();
-}
-int V4LCamera::icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
-                                  int property_id, double value ){
-    static int width = 0, height = 0;
-    int retval;
-
-    /* initialization */
-    retval = 0;
-
-    /* two subsequent calls setting WIDTH and HEIGHT will change
-       the video size */
-    /* the first one will return an error, though. */
-
-    switch (property_id) {
-    case CV_CAP_PROP_FRAME_WIDTH:
-        width = value;
-        if(width !=0 && height != 0) {
-            retval = icvSetVideoSize( capture, width, height);
-            width = height = 0;
-        }
-        break;
-    case CV_CAP_PROP_FRAME_HEIGHT:
-        height = value;
-        if(width !=0 && height != 0) {
-            retval = icvSetVideoSize( capture, width, height);
-            width = height = 0;
-        }
-        break;
+  }
+  SafeStop();
+  Join();
+}
+
+int V4LCamera::init(int width, int height) {
+  CLEAR (capture.cap);
+  if(-1 == xioctl(device, VIDIOC_QUERYCAP, &capture.cap)) {
+    return -1;
+  } else {
+    CLEAR (capture.capability);
+    capture.capability.type = capture.cap.capabilities;
+
+    /* Query channels number */
+    if (-1 == xioctl(device, VIDIOC_G_INPUT, &capture.capability.channels)) {
+      return -1;
+    }
+  }
+
+  /* Init V4L2 control variables */
+  capture.v4l2_brightness = 0;
+  capture.v4l2_contrast = 0;
+  capture.v4l2_saturation = 0;
+  capture.v4l2_hue = 0;
+  capture.v4l2_gain = 0;
+  capture.v4l2_sharpness = 0;
+  capture.v4l2_exposure = 0;
+  capture.v4l2_autogain = 0;
+  capture.v4l2_awb = 0;
+
+  capture.v4l2_brightness_min = 0;
+  capture.v4l2_contrast_min = 0;
+  capture.v4l2_saturation_min = 0;
+  capture.v4l2_hue_min = 0;
+  capture.v4l2_gain_min = 0;
+  capture.v4l2_sharpness_min = 0;
+  capture.v4l2_exposure_min = 0;
+  capture.v4l2_autogain_min = 0;
+  capture.v4l2_awb_min = 0;
+
+  capture.v4l2_brightness_max = 0;
+  capture.v4l2_contrast_max = 0;
+  capture.v4l2_saturation_max = 0;
+  capture.v4l2_hue_max = 0;
+  capture.v4l2_gain_max = 0;
+  capture.v4l2_sharpness_max = 0;
+  capture.v4l2_exposure_max = 0;
+  capture.v4l2_autogain_max = 0;
+  capture.v4l2_awb_max = 0;
+     
+  if ((capture.cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
+    Thread::Err("device is unable to capture video memory.\n");
+    return -1;
+  }
+
+  /* Find Window info */
+  CLEAR (capture.form);
+  capture.form.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+      
+  if (-1 == xioctl (device, VIDIOC_G_FMT, &capture.form)) {
+     Thread::Err("Could not obtain specifics of capture window.\n");
+     return -1;
+  }
+
+  if (autosetup_capture_mode_v4l2(&capture) == -1) {
+     return -1;
+  }
+
+  icvSetVideoSize(&capture, width, height);
+
+  unsigned int min;
+
+  /* Buggy driver paranoia. */
+  min = capture.form.fmt.pix.width * 2;
+  if (capture.form.fmt.pix.bytesperline < min) {
+   capture.form.fmt.pix.bytesperline = min;
+  }
+
+  min = capture.form.fmt.pix.bytesperline * capture.form.fmt.pix.height;
+  if (capture.form.fmt.pix.sizeimage < min) {
+   capture.form.fmt.pix.sizeimage = min;
+  }
+
+  return 1;
+}
+
+int V4LCamera::setV4LProperty(int property_id, double value){
+  int retval=0;
+  switch (property_id) {
     case CV_CAP_PROP_FORMAT:
-
-	capture->form.fmt.pix.pixelformat = (unsigned long)value; 
- 	retval == xioctl (capture->deviceHandle, VIDIOC_S_FMT, &capture->form);
-	if ((unsigned long)value != capture->form.fmt.pix.pixelformat)
-   		retval=-1;
-
-	
-	PALETTE_YUYV = 0;
-	PALETTE_UYVY= 0;
-	
-
-	if ((unsigned long)value== V4L2_PIX_FMT_YUYV)
-	{
-		PALETTE_YUYV = 1;
-	}
-	if ((unsigned long)value== V4L2_PIX_FMT_UYVY)
-	{
-		PALETTE_UYVY = 1;
-	}
-	
-
-	break;
-    case CV_CAP_PROP_BRIGHTNESS:
-    case CV_CAP_PROP_CONTRAST:
-    case CV_CAP_PROP_SATURATION:
-    case CV_CAP_PROP_HUE:
-    case CV_CAP_PROP_GAIN:
-    case CV_CAP_PROP_SHARPNESS:
-    case CV_CAP_PROP_EXPOSURE:
-    case CV_CAP_PROP_AUTOGAIN:
-    case CV_CAP_PROP_AWB:
-        retval = icvSetControl(capture, property_id, value);
-        break;
+      capture.form.fmt.pix.pixelformat = (unsigned long)value; 
+      retval == xioctl(device, VIDIOC_S_FMT, &capture.form);
+      if ((unsigned long)value != capture.form.fmt.pix.pixelformat) {
+        retval=-1;
+      }
+      PALETTE_YUYV = 0;
+      PALETTE_UYVY= 0;
+      if((unsigned long)value== V4L2_PIX_FMT_YUYV) {
+        PALETTE_YUYV = 1;
+      }
+      if((unsigned long)value== V4L2_PIX_FMT_UYVY) {
+        PALETTE_UYVY = 1;
+      }
+      break;
     default:
-        fprintf(stderr,
-                "HIGHGUI ERROR: V4L: setting property #%d is not supported\n",
-                property_id);
-    }
-
-    /* return the the status */
-    return retval;
-}
-int V4LCamera::icvSetControl (CvCaptureCAM_V4L* capture,
-                          int property_id, double value) {
+      Thread::Warn("setting property #%d is not supported\n",property_id);
+  }
+
+  return retval;
+}
+
+int V4LCamera::icvSetControl(CvCaptureCAM_V4L* capture,int property_id, double value) {
   
   /* limitation of the input value */
@@ -260,6 +284,5 @@
 
     /* get the min and max values */
-    if (-1 == xioctl (capture->deviceHandle,
-                      VIDIOC_G_CTRL, &capture->control)) {
+    if (-1 == xioctl (device,VIDIOC_G_CTRL, &capture->control)) {
 //          perror ("VIDIOC_G_CTRL for getting min/max values");
           return -1;
@@ -351,6 +374,5 @@
 
     /* The driver may clamp the value or return ERANGE, ignored here */
-    if (-1 == xioctl (capture->deviceHandle,
-                      VIDIOC_S_CTRL, &capture->control) && errno != ERANGE) {
+    if (-1 == xioctl (device,VIDIOC_S_CTRL, &capture->control) && errno != ERANGE) {
         perror ("VIDIOC_S_CTRL");
         return -1;
@@ -361,88 +383,6 @@
 
 }
-int V4LCamera::_capture_V4L2 (CvCaptureCAM_V4L *capture)
-{
-   int detect_v4l2 = 0;
-
-   detect_v4l2 = try_init_v4l2(capture);
-
-   if (detect_v4l2 != 1) {
-       /* init of the v4l2 device is not OK */
-       return -1;
-   }
-
-   /* Init V4L2 control variables */
-   capture->v4l2_brightness = 0;
-   capture->v4l2_contrast = 0;
-   capture->v4l2_saturation = 0;
-   capture->v4l2_hue = 0;
-   capture->v4l2_gain = 0;
-   capture->v4l2_sharpness = 0;
-   capture->v4l2_exposure = 0;
-   capture->v4l2_autogain = 0;
-   capture->v4l2_awb = 0;
-
-   capture->v4l2_brightness_min = 0;
-   capture->v4l2_contrast_min = 0;
-   capture->v4l2_saturation_min = 0;
-   capture->v4l2_hue_min = 0;
-   capture->v4l2_gain_min = 0;
-   capture->v4l2_sharpness_min = 0;
-   capture->v4l2_exposure_min = 0;
-   capture->v4l2_autogain_min = 0;
-   capture->v4l2_awb_min = 0;
-
-   capture->v4l2_brightness_max = 0;
-   capture->v4l2_contrast_max = 0;
-   capture->v4l2_saturation_max = 0;
-   capture->v4l2_hue_max = 0;
-   capture->v4l2_gain_max = 0;
-   capture->v4l2_sharpness_max = 0;
-   capture->v4l2_exposure_max = 0;
-   capture->v4l2_autogain_max = 0;
-   capture->v4l2_awb_max = 0;
-     
-  
-   if ((capture->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
-      /* Nope. */
-      fprintf( stderr, "HIGHGUI ERROR: V4L2: device is unable to capture video memory.\n");
-      
-      return -1;
-   }
-
-  
-
-   /* Find Window info */
-   CLEAR (capture->form);
-   capture->form.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-        
-   if (-1 == xioctl (capture->deviceHandle, VIDIOC_G_FMT, &capture->form)) {
-       fprintf( stderr, "HIGHGUI ERROR: V4L2: Could not obtain specifics of capture window.\n\n");
-       
-       return -1;
-   }
-
-  
-
-   if (autosetup_capture_mode_v4l2(capture) == -1)
-       return -1;
-
-   icvSetVideoSize(capture, DEFAULT_V4L_WIDTH, DEFAULT_V4L_HEIGHT);
-
-   unsigned int min;
-
-   /* Buggy driver paranoia. */
-   min = capture->form.fmt.pix.width * 2;
-
-   if (capture->form.fmt.pix.bytesperline < min)
-       capture->form.fmt.pix.bytesperline = min;
-
-   min = capture->form.fmt.pix.bytesperline * capture->form.fmt.pix.height;
- 
-   if (capture->form.fmt.pix.sizeimage < min)
-       capture->form.fmt.pix.sizeimage = min;
-
-   return 1;
-}
+
+
 int V4LCamera::icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h) {
 
@@ -457,5 +397,5 @@
 
     /* set the crop area, but don't exit if the device don't support croping */
-    xioctl (capture->deviceHandle, VIDIOC_S_CROP, &capture->crop);
+    xioctl (device, VIDIOC_S_CROP, &capture->crop);
 
     CLEAR (capture->form);
@@ -463,5 +403,5 @@
 
     /* read the current setting, mainly to retreive the pixelformat information */
-    xioctl (capture->deviceHandle, VIDIOC_G_FMT, &capture->form);
+    xioctl (device, VIDIOC_G_FMT, &capture->form);
 
     /* set the values we want to change */
@@ -478,5 +418,5 @@
      * don't allow changing the size, and we will get the real size
      * later */
-    xioctl (capture->deviceHandle, VIDIOC_S_FMT, &capture->form);
+    xioctl (device, VIDIOC_S_FMT, &capture->form);
 
     /* try to set framerate to 30 fps */
@@ -486,5 +426,5 @@
     setfps.parm.capture.timeperframe.numerator = 1;
     setfps.parm.capture.timeperframe.denominator = 30;
-    xioctl (capture->deviceHandle, VIDIOC_S_PARM, &setfps);
+    xioctl (device, VIDIOC_S_PARM, &setfps);
 
     /* we need to re-initialize some things, like buffers, because the size has
@@ -493,5 +433,5 @@
 
     /* Get window info again, to get the real value */
-    if (-1 == xioctl (capture->deviceHandle, VIDIOC_G_FMT, &capture->form))
+    if (-1 == xioctl (device, VIDIOC_G_FMT, &capture->form))
     {
       fprintf(stderr, "HIGHGUI ERROR: V4L/V4L2: Could not obtain specifics of capture window.\n\n");
@@ -520,5 +460,5 @@
   capture->form.fmt.pix.height = DEFAULT_V4L_HEIGHT;
   
-  if (-1 == xioctl (capture->deviceHandle, VIDIOC_S_FMT, &capture->form))
+  if (-1 == xioctl (device, VIDIOC_S_FMT, &capture->form))
       return -1;
 
@@ -545,40 +485,4 @@
 }
 
-
-
-int V4LCamera::try_init_v4l2(CvCaptureCAM_V4L* capture)
-{
-
-  // if detect = -1 then unable to open device
-  // if detect = 0 then detected nothing
-  // if detect = 1 then V4L2 device 
-  int detect = 0;
-
-
-  if (detect == 0)
-  {
-    CLEAR (capture->cap);
-    if (-1 == xioctl (capture->deviceHandle, VIDIOC_QUERYCAP, &capture->cap))
-    {
-      detect = 0;
-
-      
-    }
-      else
-    {
-      CLEAR (capture->capability);
-      capture->capability.type = capture->cap.capabilities;
-     
-      /* Query channels number */
-      if (-1 != xioctl (capture->deviceHandle, VIDIOC_G_INPUT, &capture->capability.channels))
-      {
-        detect = 1;
-      }
-    }
-  }
-
-  return detect;
-
-}
 /*
 V4LCamera::V4LCamera(string name,
@@ -776,5 +680,5 @@
    capture->req.memory = V4L2_MEMORY_MMAP;
 
-   if (-1 == xioctl (capture->deviceHandle, VIDIOC_REQBUFS, &capture->req))
+   if (-1 == xioctl (device, VIDIOC_REQBUFS, &capture->req))
    {
        if (EINVAL == errno)
@@ -816,5 +720,5 @@
        buf.index = n_buffers;
 
-       if (-1 == xioctl (capture->deviceHandle, VIDIOC_QUERYBUF, &buf)) {
+       if (-1 == xioctl (device, VIDIOC_QUERYBUF, &buf)) {
            perror ("VIDIOC_QUERYBUF");
        
@@ -830,5 +734,5 @@
                PROT_READ | PROT_WRITE /* required */,
                MAP_SHARED /* recommended */,
-               capture->deviceHandle, buf.m.offset);
+               device, buf.m.offset);
 
        if (MAP_FAILED == capture->buffers[n_buffers].start) {
@@ -880,5 +784,5 @@
           buf.index       = (unsigned long)capture->bufferIndex;
 
-          if (-1 == xioctl (capture->deviceHandle, VIDIOC_QBUF, &buf)) {
+          if (-1 == xioctl (device, VIDIOC_QBUF, &buf)) {
               perror ("VIDIOC_QBUF");
               return 0;
@@ -888,5 +792,5 @@
         /* enable the streaming */
         capture->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-        if (-1 == xioctl (capture->deviceHandle, VIDIOC_STREAMON,
+        if (-1 == xioctl (device, VIDIOC_STREAMON,
                           &capture->type)) {
             /* error enabling the stream */
@@ -922,5 +826,5 @@
 
             FD_ZERO (&fds);
-            FD_SET (capture->deviceHandle, &fds);
+            FD_SET (device, &fds);
 
             /* Timeout. */
@@ -928,5 +832,5 @@
             tv.tv_usec = 0;
 
-            r = select (capture->deviceHandle+1, &fds, NULL, NULL, &tv);
+            r = select (device+1, &fds, NULL, NULL, &tv);
 
             if (-1 == r) {
@@ -957,5 +861,5 @@
     buf.memory = V4L2_MEMORY_MMAP;
 
-    if (-1 == xioctl (capture->deviceHandle, VIDIOC_DQBUF, &buf)) {
+    if (-1 == xioctl (device, VIDIOC_DQBUF, &buf)) {
         switch (errno) {
         case EAGAIN:
@@ -982,5 +886,5 @@
 
 
-   if (-1 == xioctl (capture->deviceHandle, VIDIOC_QBUF, &buf))
+   if (-1 == xioctl (device, VIDIOC_QBUF, &buf))
        perror ("VIDIOC_QBUF");
 
Index: /trunk/lib/FlairSensorActuator/src/V4LCamera.h
===================================================================
--- /trunk/lib/FlairSensorActuator/src/V4LCamera.h	(revision 345)
+++ /trunk/lib/FlairSensorActuator/src/V4LCamera.h	(revision 346)
@@ -22,12 +22,12 @@
 
 namespace flair {
-namespace core {
-class Image;
-}
-namespace gui {
-class DoubleSpinBox;
-class CheckBox;
-class Label;
-}
+  namespace core {
+    class Image;
+  }
+  namespace gui {
+    class DoubleSpinBox;
+    class CheckBox;
+    class Label;
+  }
 }
 
@@ -166,5 +166,5 @@
     typedef struct CvCaptureCAM_V4L
 {
-    int deviceHandle;
+    //int deviceHandle;
     int bufferIndex;
     int FirstCapture;
@@ -209,11 +209,10 @@
 
 CvCaptureCAM_V4L capture;
-int _capture_V4L2 (CvCaptureCAM_V4L *capture);
-int try_init_v4l2(CvCaptureCAM_V4L* capture);
+int init(int width, int height);
 int autosetup_capture_mode_v4l2(CvCaptureCAM_V4L* capture);
 int icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h);
 int try_palette_v4l2(CvCaptureCAM_V4L* capture, unsigned long colorspace);
 int  PALETTE_YUYV,PALETTE_UYVY;
-int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,int property_id, double value );
+int setV4LProperty(int property_id, double value );
 int icvSetControl (CvCaptureCAM_V4L* capture,int property_id, double value) ;
 int cvGrabFrame(CvCaptureCAM_V4L* capture);
