Example #1
0
void DC1394Camera::setWhiteBalance(uint32_t uValue, uint32_t vValue,
                                   bool makeAuto)
{
    // Grab the white balance feature
    dc1394feature_info_t whiteBalance;
    whiteBalance.id = DC1394_FEATURE_WHITE_BALANCE;

    if (makeAuto) {
        LOGGER.infoStream() << m_guid << ": Setting white balance automatically";
    } else {
        LOGGER.infoStream() << m_guid << ": Setting white balance to "
                            << "U Value: " << uValue << " "
                            << "V Value: " << vValue;
    }

    dc1394error_t err = dc1394_feature_get(m_camera, &whiteBalance);
    assert(DC1394_SUCCESS == err && "Could not get white balance feature info");
    
    // Make sure its available
    assert((whiteBalance.available == DC1394_TRUE) &&
           "White balance not supported by camera");

    if (makeAuto)
    {
        err = dc1394_feature_set_mode(m_camera, DC1394_FEATURE_WHITE_BALANCE,
                                      DC1394_FEATURE_MODE_AUTO);
        assert(DC1394_SUCCESS == err && "Could not set whitebalance to auto");
    }
    else
    {
        // Set manual mode
        err = dc1394_feature_set_mode(m_camera, DC1394_FEATURE_WHITE_BALANCE,
                                      DC1394_FEATURE_MODE_MANUAL);
        assert(DC1394_SUCCESS == err && "Could not set whitebalance to manual");

        // Store the values
        uint32_t whiteMax = whiteBalance.max;
        uint32_t whiteMin = whiteBalance.min;
        
        // Error on out of bounds values
        if (((uValue > whiteMax) || (uValue < whiteMin)) ||
            ((vValue > whiteMax) || (vValue < whiteMin)))
        {
            fprintf(stderr, "ERROR: WhiteBalance out of bounds: (%u, %u)\n",
                    whiteMin, whiteMax);
            assert(false && "White balance out of bounds");
        }
        
        // Set values
        err = dc1394_feature_whitebalance_set_value(m_camera, uValue, vValue);
        assert(DC1394_SUCCESS == err && "Could not set whitebalance");
    }

    LOGGER.infoStream() << m_guid << ": Successfully set white balance";
}
Example #2
0
void FWCamera::setWhitebalance(int u, int v, bool bIgnoreOldValue)
{
#ifdef AVG_ENABLE_1394_2
    if (hasFeature(CAM_FEATURE_WHITE_BALANCE)) {
        if (bIgnoreOldValue || u != m_WhitebalanceU || v != m_WhitebalanceV) {
            m_WhitebalanceU = u;
            m_WhitebalanceV = v;
            dc1394error_t err;
            if (u == -1) {
                err = dc1394_feature_set_mode(m_pCamera, DC1394_FEATURE_WHITE_BALANCE,
                        DC1394_FEATURE_MODE_AUTO);
            } else {
                err = dc1394_feature_set_mode(m_pCamera, DC1394_FEATURE_WHITE_BALANCE, 
                        DC1394_FEATURE_MODE_MANUAL);
                err = dc1394_feature_whitebalance_set_value(m_pCamera, u, v);
            }
            if (err != DC1394_SUCCESS) {
                AVG_LOG_WARNING("Camera: Unable to set whitebalance. Error was " << err);
            }
        }
    }
#endif
}
Example #3
0
int main(int argc,char *argv[])
{
  XEvent xev;
  XGCValues xgcv;
  long background=0x010203;
  int i, j;
  dc1394_t * d;
  dc1394camera_list_t * list;

  get_options(argc,argv);
  /* process options */
  switch(fps) {
  case 1: fps =        DC1394_FRAMERATE_1_875; break;
  case 3: fps =        DC1394_FRAMERATE_3_75; break;
  case 15: fps = DC1394_FRAMERATE_15; break;
  case 30: fps = DC1394_FRAMERATE_30; break;
  case 60: fps = DC1394_FRAMERATE_60; break;
  default: fps = DC1394_FRAMERATE_7_5; break;
  }
  switch(res) {
  case 1:
    res = DC1394_VIDEO_MODE_640x480_YUV411;
    device_width=640;
    device_height=480;
    format=XV_YUY2;
    break;
  case 2:
    res = DC1394_VIDEO_MODE_640x480_RGB8;
    device_width=640;
    device_height=480;
    format=XV_YUY2;
    break;
  case 3:
    res = DC1394_VIDEO_MODE_800x600_YUV422;
    device_width=800;
    device_height=600;
    format=XV_UYVY;
    break;
  default:
    res = DC1394_VIDEO_MODE_320x240_YUV422;
    device_width=320;
    device_height=240;
    format=XV_UYVY;
    break;
  }

  dc1394error_t err;

  d = dc1394_new ();
  if (!d)
    return 1;
  err=dc1394_camera_enumerate (d, &list);
  DC1394_ERR_RTN(err,"Failed to enumerate cameras");

  if (list->num == 0) {
    dc1394_log_error("No cameras found");
    return 1;
  }

  j = 0;
  for (i = 0; i < list->num; i++) {
    if (j >= MAX_CAMERAS)
      break;
    cameras[j] = dc1394_camera_new (d, list->ids[i].guid);
    if (!cameras[j]) {
      dc1394_log_warning("Failed to initialize camera with guid %llx", list->ids[i].guid);
      continue;
    }
    j++;
  }
  numCameras = j;
  dc1394_camera_free_list (list);

  if (numCameras == 0) {
    dc1394_log_error("No cameras found");
    exit (1);
  }

  /* setup cameras for capture */
  for (i = 0; i < numCameras; i++) {
      
    //err=dc1394_video_set_iso_speed(cameras[i], DC1394_ISO_SPEED_400);
    //dc1394_video_set_operation_mode(my_camera_ptr[i], DC1394_OPERATION_MODE_1394B);
    err= dc1394_video_set_operation_mode(cameras[i], DC1394_OPERATION_MODE_1394B);
    err=dc1394_video_set_iso_speed(cameras[i], DC1394_ISO_SPEED_800);
    DC1394_ERR_CLN_RTN(err,cleanup(),"Could not set ISO speed");

    err=dc1394_video_set_mode(cameras[i], res);
    DC1394_ERR_CLN_RTN(err,cleanup(),"Could not set video mode");

    err=dc1394_video_set_framerate(cameras[i], fps);
    DC1394_ERR_CLN_RTN(err,cleanup(),"Could not set framerate");

    err=dc1394_capture_setup(cameras[i],NUM_BUFFERS, DC1394_CAPTURE_FLAGS_DEFAULT);
    DC1394_ERR_CLN_RTN(err,cleanup(),"Could not setup camera-\nmake sure that the video mode and framerate are\nsupported by your camera");

    err=dc1394_video_set_transmission(cameras[i], DC1394_ON);
    DC1394_ERR_CLN_RTN(err,cleanup(),"Could not start camera iso transmission");

    // Camera settings
    err = dc1394_feature_set_value(cameras[i],DC1394_FEATURE_SHUTTER,1400);
    err = dc1394_feature_set_value(cameras[i],DC1394_FEATURE_BRIGHTNESS,800);
    err = dc1394_feature_set_value(cameras[i],DC1394_FEATURE_EXPOSURE,150);
    err = dc1394_feature_whitebalance_set_value(cameras[i],500,400);

  }

  fflush(stdout);
  if (numCameras < 1) {
    perror("no cameras found :(\n");
    cleanup();
    exit(-1);
  }

  switch(format){
  case XV_YV12:
    set_frame_length(device_width*device_height*3/2, numCameras);
    break;
  case XV_YUY2:
  case XV_UYVY:
    set_frame_length(device_width*device_height*2, numCameras);
    break;
  default:
    dc1394_log_error("Unknown format set (internal error)");
    exit(255);
  }

  /* make the window */
  display=XOpenDisplay(getenv("DISPLAY"));
  if(display==NULL) {
    dc1394_log_error("Could not open display \"%s\"",getenv("DISPLAY"));
    cleanup();
    exit(-1);
  }

  QueryXv();

  if ( adaptor < 0 ) {
    cleanup();
    exit(-1);
  }

  width=device_width;
  height=device_height * numCameras;
  //width=device_width * numCameras;
  //height=device_height;

  window=XCreateSimpleWindow(display,DefaultRootWindow(display),0,0,width,height,0,
			     WhitePixel(display,DefaultScreen(display)),
			     background);

  XSelectInput(display,window,StructureNotifyMask|KeyPressMask);
  XMapWindow(display,window);
  connection=ConnectionNumber(display);

  gc=XCreateGC(display,window,0,&xgcv);

  /* main event loop */
  while(1){

    for (i = 0; i < numCameras; i++) {
      if (dc1394_capture_dequeue(cameras[i], DC1394_CAPTURE_POLICY_WAIT, &frames[i])!=DC1394_SUCCESS)
	dc1394_log_error("Failed to capture from camera %d", i);
    }

    display_frames();
    XFlush(display);

    while(XPending(display)>0){
      XNextEvent(display,&xev);
      switch(xev.type){
      case ConfigureNotify:
	width=xev.xconfigure.width;
	height=xev.xconfigure.height;
	display_frames();
	break;
      case KeyPress:
	switch(XKeycodeToKeysym(display,xev.xkey.keycode,0)){
	case XK_q:
	case XK_Q:
	  cleanup();
	  exit(0);
	  break;
	case XK_comma:
	case XK_less:
	  //width=width/2;
	  //height=height/2;
	  width--;
	  XResizeWindow(display,window,width,height);
	  display_frames();
	  break;
	case XK_period:
	case XK_greater:
	  //width=2*width;
	  //height=2*height;
	  width++;
	  XResizeWindow(display,window,width,height);
	  display_frames();
	  break;
	case XK_0:
	  freeze = !freeze;
	  break;
	case XK_1:
	  fps =        DC1394_FRAMERATE_1_875;
	  for (i = 0; i < numCameras; i++)
	    dc1394_video_set_framerate(cameras[i], fps);
	  break;
	case XK_2:
	  fps =        DC1394_FRAMERATE_3_75;
	  for (i = 0; i < numCameras; i++)
	    dc1394_video_set_framerate(cameras[i], fps);
	  break;
	case XK_4:
	  fps = DC1394_FRAMERATE_15;
	  for (i = 0; i < numCameras; i++)
	    dc1394_video_set_framerate(cameras[i], fps);
	  break;
	case XK_5:
	  fps = DC1394_FRAMERATE_30;
	  for (i = 0; i < numCameras; i++)
	    dc1394_video_set_framerate(cameras[i], fps);
	  break;
	case XK_3:
	  fps = DC1394_FRAMERATE_7_5;
	  for (i = 0; i < numCameras; i++)
	    dc1394_video_set_framerate(cameras[i], fps);
	  break;
	}
	break;
      }
    } /* XPending */

    for (i = 0; i < numCameras; i++) {
      if (frames[i])
	dc1394_capture_enqueue (cameras[i], frames[i]);
    }

  } /* while not interrupted */

  exit(0);
}
Example #4
0
static int s_set_parameters(capture_t *cap, const int index, camera_setting_t *s)
{
  int ret = CAPTURE_SUCCESS;

  dc1394camera_t *cam = cap->cameras[index];
  dc1394error_t err;

  /* set operation mode to 1394b, if possible */
  if (cam->bmode_capable != 0 && cap->prefer_bmode) {
    err = dc1394_video_set_operation_mode(cam, DC1394_OPERATION_MODE_1394B);
    DC1394_WRN(err, "could not set 1394b mode.");

    if (err == DC1394_SUCCESS) {
      err = dc1394_video_set_iso_speed(cam, DC1394_ISO_SPEED_800);
      DC1394_WRN(err, "could not set iso mode to S800.");

      if (err != DC1394_SUCCESS) {
        err = dc1394_video_set_iso_speed(cam, DC1394_ISO_SPEED_400);
        DC1394_WRN(err, "could not set iso mode to S400.");
      }
    }
  }
  else {
    err = dc1394_video_set_operation_mode(cam, DC1394_OPERATION_MODE_LEGACY);
    DC1394_WRN(err, "could not set 1394-legacy mode.");

    err = dc1394_video_set_iso_speed(cam, DC1394_ISO_SPEED_400);
    DC1394_WRN(err, "could not set iso mode to S400.");
  }

  /* mode */
  s->mode = s_get_appropriate_mode(cam, ((s->mode >= 0) ? s->mode : DC1394_VIDEO_MODE_640x480_MONO8));
  if (dc1394_video_set_mode(cam, s->mode) != DC1394_SUCCESS) {
    ret = CAPTURE_ERROR;
  }
  dc1394_video_get_mode(cam, &s->mode);

  /* frame rate */
  s->framerate = s_get_appropriate_framerate(cam, s->mode, ((s->framerate >= 0) ? s->framerate : DC1394_FRAMERATE_30));
  if (dc1394_video_set_framerate(cam, s->framerate) != DC1394_SUCCESS) {
    ret = CAPTURE_ERROR;
  }

  /*
    features
  */
  SET_FEATURE(DC1394_FEATURE_BRIGHTNESS,    s->brightness);
  SET_FEATURE(DC1394_FEATURE_EXPOSURE,      s->exposure);
  SET_FEATURE(DC1394_FEATURE_SHARPNESS,     s->sharpness);
  SET_FEATURE(DC1394_FEATURE_HUE,           s->hue);
  SET_FEATURE(DC1394_FEATURE_SATURATION,    s->saturation);
  SET_FEATURE(DC1394_FEATURE_GAMMA,         s->gamma);
  SET_FEATURE(DC1394_FEATURE_SHUTTER,       s->shutter);
  SET_FEATURE(DC1394_FEATURE_GAIN,          s->gain);
  SET_FEATURE(DC1394_FEATURE_IRIS,          s->iris);
  SET_FEATURE(DC1394_FEATURE_FOCUS,         s->focus);
  //SET_FEATURE(DC1394_FEATURE_TEMPERATURE,   s->temperature); is not supported by dc1394_feature_set_value()
  
  SET_FEATURE(DC1394_FEATURE_ZOOM, s->zoom);
  SET_FEATURE(DC1394_FEATURE_PAN,  s->pan);
  SET_FEATURE(DC1394_FEATURE_TILT, s->tilt);

  /* white blance */
  if (s->white_balance[0] >= 0 && s->white_balance[1] >= 0) {
    dc1394_feature_set_mode(cam, DC1394_FEATURE_WHITE_BALANCE, DC1394_FEATURE_MODE_MANUAL);
    if (dc1394_feature_whitebalance_set_value(cam, s->white_balance[0], s->white_balance[1]) != DC1394_SUCCESS) {
      ret = CAPTURE_ERROR;
    }
  }
  else {
    if (dc1394_feature_set_mode(cam, DC1394_FEATURE_WHITE_BALANCE, DC1394_FEATURE_MODE_AUTO) != DC1394_SUCCESS) {
      ret = CAPTURE_ERROR;
    }
  }

  return ret;
}
Example #5
0
bool CvCaptureCAM_DC1394_v2_CPP::setProperty(int propId, double value)
{
    switch (propId)
    {
    case CV_CAP_PROP_FRAME_WIDTH:
        if(started)
            return false;
        frameWidth = cvRound(value);
        frameHeight = 0;
        break;
    case CV_CAP_PROP_FRAME_HEIGHT:
        if(started)
            return false;
        frameWidth = 0;
        frameHeight = cvRound(value);
        break;
    case CV_CAP_PROP_FPS:
        if(started)
            return false;
        fps = value;
        break;
    case CV_CAP_PROP_RECTIFICATION:
        if( cameraId != VIDERE )
            return false;
        rectify = fabs(value) > FLT_EPSILON;
        break;
    case CV_CAP_PROP_MODE:
        if(started)
            return false;
        userMode = cvRound(value);
        break;
    case CV_CAP_PROP_ISO_SPEED:
        if(started)
            return false;
        isoSpeed = cvRound(value);
        break;
    //The code below is based on coriander, callbacks.c:795, refer to case RANGE_MENU_MAN :
    default:
        if (propId<CV_CAP_PROP_MAX_DC1394 && dc1394properties[propId]!=-1
                && dcCam)
        {
            //get the corresponding feature from property-id
            dc1394feature_info_t *act_feature = &feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN];

            if (cvRound(value) == CV_CAP_PROP_DC1394_OFF)
            {
                if (  (act_feature->on_off_capable)
                        && (dc1394_feature_set_power(dcCam, act_feature->id, DC1394_OFF) == DC1394_SUCCESS))
                {
                    act_feature->is_on=DC1394_OFF;
                    return true;
                }
                return false;
            }
            //try to turn the feature ON, feature can be ON and at the same time it can be not capable to change state to OFF
            if ( (act_feature->is_on == DC1394_OFF) && (act_feature->on_off_capable == DC1394_TRUE))
            {
                if (dc1394_feature_set_power(dcCam, act_feature->id, DC1394_ON) == DC1394_SUCCESS)
                    feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].is_on=DC1394_ON;
            }
            //turn off absolute mode - the actual value will be stored in the value field,
            //otherwise it would be stored into CSR (control and status register) absolute value
            if (act_feature->absolute_capable
                    && dc1394_feature_set_absolute_control(dcCam, act_feature->id, DC1394_OFF) !=DC1394_SUCCESS)
                return false;
            else
                act_feature->abs_control=DC1394_OFF;
            //set AUTO
            if (cvRound(value) == CV_CAP_PROP_DC1394_MODE_AUTO)
            {
                if (dc1394_feature_set_mode(dcCam, act_feature->id, DC1394_FEATURE_MODE_AUTO)!=DC1394_SUCCESS)
                    return false;
                act_feature->current_mode=DC1394_FEATURE_MODE_AUTO;
                return true;
            }
            //set ONE PUSH
            if (cvRound(value) == CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO)
            {
                //have to set to manual first, otherwise one push will be ignored (AVT  manual 4.3.0 p. 115)
                if (dc1394_feature_set_mode(dcCam, act_feature->id, DC1394_FEATURE_MODE_ONE_PUSH_AUTO)!=DC1394_SUCCESS)
                    return false;
                //will change to
                act_feature->current_mode=DC1394_FEATURE_MODE_ONE_PUSH_AUTO;
                return true;
            }
            //set the feature to MANUAL mode,
            if (dc1394_feature_set_mode(dcCam, act_feature->id, DC1394_FEATURE_MODE_MANUAL)!=DC1394_SUCCESS)
                return false;
            else
                act_feature->current_mode=DC1394_FEATURE_MODE_MANUAL;
            // if property is one of the white balance features treat it in different way
            if (propId == CV_CAP_PROP_WHITE_BALANCE_BLUE_U)
            {
                if (dc1394_feature_whitebalance_set_value(dcCam,cvRound(value), act_feature->RV_value)!=DC1394_SUCCESS)
                    return false;
                else
                {
                    act_feature->BU_value = cvRound(value);
                    return true;
                }
            }
            if (propId == CV_CAP_PROP_WHITE_BALANCE_RED_V)
            {
                if (dc1394_feature_whitebalance_set_value(dcCam, act_feature->BU_value, cvRound(value))!=DC1394_SUCCESS)
                    return false;
                else
                {
                    act_feature->RV_value = cvRound(value);
                    return true;
                }
            }

            //first: check boundaries
            if (value < act_feature->min)
            {
                value = act_feature->min;
            }
            else if (value > act_feature->max)
            {
                value = act_feature->max;
            }

            if (dc1394_feature_set_value(dcCam, act_feature->id, cvRound(value)) == DC1394_SUCCESS)
            {
                act_feature->value = value;
                return true;
            }
        }
        return false;
    }
    return true;
}
Example #6
0
void of1394VideoGrabber::setWhiteBalance(unsigned int a, unsigned int b)
{
	dc1394_feature_set_mode(camera, DC1394_FEATURE_WHITE_BALANCE, DC1394_FEATURE_MODE_MANUAL);
	dc1394_feature_whitebalance_set_value(camera, a, b);
}
Example #7
0
/** Configure a feature for the currently open device.
 *
 *  @pre feature_set_ initialized
 *
 *  @param feature desired feature number
 *  @param control [in,out] pointer to control parameter (may change)
 *  @param value [in,out] pointer to requested parameter value (may
 *               change depending on device restrictions)
 *  @param value2 [in,out] optional pointer to second parameter value
 *               for white balance (may change depending on device
 *               restrictions).  No second value if NULL pointer.
 *
 *  The parameter values are represented as double despite the fact
 *  that most features on most cameras only allow unsigned 12-bit
 *  values.  The exception is the rare feature that supports
 *  "absolute" values in 32-bit IEEE float format.  Double can
 *  represent all possible option values accurately.
 */
void Features::configure(dc1394feature_t feature, int *control,
                         double *value, double *value2)
{
  // device-relevant information for this feature
  dc1394feature_info_t *finfo =
    &feature_set_.feature[feature - DC1394_FEATURE_MIN];

  if (!finfo->available)                // feature not available?
    {
      *control = camera1394::Camera1394_None;
      return;
    }

  switch (*control)
    {
    case camera1394::Camera1394_Off:
      setPower(finfo, DC1394_OFF);
      break;

    case camera1394::Camera1394_Query:
      getValues(finfo, value, value2);
      break;

    case camera1394::Camera1394_Auto:
      if (!setMode(finfo, DC1394_FEATURE_MODE_AUTO))
        {
          setPower(finfo, DC1394_OFF);
        }
      break;

    case camera1394::Camera1394_Manual:
      if (!setMode(finfo, DC1394_FEATURE_MODE_MANUAL))
        {
          setPower(finfo, DC1394_OFF);
          break;
        }

      // TODO: break this into some internal methods
      if (finfo->absolute_capable && finfo->abs_control)
        {
          // supports reading and setting float value
          float fmin, fmax;
          if (DC1394_SUCCESS ==
              dc1394_feature_get_absolute_boundaries(camera_, feature,
                                                     &fmin, &fmax))
            {
              // clamp *value between minimum and maximum
              if (*value < fmin)
                *value = (double) fmin;
              else if (*value > fmax)
                *value = (double) fmax;
            }
          else
            {
              ROS_WARN_STREAM("failed to get feature "
                              << featureName(feature) << " boundaries ");
            }

          // @todo handle absolute White Balance values
          float fval = *value;
          if (DC1394_SUCCESS !=
              dc1394_feature_set_absolute_value(camera_, feature, fval))
            {
              ROS_WARN_STREAM("failed to set feature "
                              << featureName(feature) << " to " << fval);
            }
        }
      else // no float representation
        {
          // round requested value to nearest integer
          *value = rint(*value);

          // clamp *value between minimum and maximum
          if (*value < finfo->min)
            *value = (double) finfo->min;
          else if (*value > finfo->max)
            *value = (double) finfo->max;

          dc1394error_t rc;
          uint32_t ival = (uint32_t) *value;

          // handle White Balance, which has two components
          if (feature == DC1394_FEATURE_WHITE_BALANCE)
            {
              *value2 = rint(*value2);

              // clamp *value2 between same minimum and maximum
              if (*value2 < finfo->min)
                *value2 = (double) finfo->min;
              else if (*value2 > finfo->max)
                *value2 = (double) finfo->max;

              uint32_t ival2 = (uint32_t) *value2;
              rc = dc1394_feature_whitebalance_set_value(camera_, ival, ival2);
            }
          else
            {
              // other features only have one component
              rc = dc1394_feature_set_value(camera_, feature, ival);
            }
          if (rc != DC1394_SUCCESS)
            {
              ROS_WARN_STREAM("failed to set feature "
                              << featureName(feature) << " to " << ival);
            }
        }
      break;

    case camera1394::Camera1394_OnePush:
      // Try to set OnePush mode
      setMode(finfo, DC1394_FEATURE_MODE_ONE_PUSH_AUTO);

      // Now turn the control off, so camera does not continue adjusting
      setPower(finfo, DC1394_OFF);
      break;

    case camera1394::Camera1394_None:
      // Invalid user input, because this feature actually does exist.
      ROS_INFO_STREAM("feature " << featureName(feature)
                      << " exists, cannot set to None");
      break;

    default:
      ROS_WARN_STREAM("unknown state (" << *control
                      <<") for feature " << featureName(feature));
    }

  // return actual state reported by the device
  *control = getState(finfo);
  ROS_DEBUG_STREAM("feature " << featureName(feature)
                   << " now in state " << *control);
}
int ar2VideoSetValue1394(AR2VideoParam1394T *vid, int paramName, int value)
{
    unsigned int ub, vr;

    switch (paramName)
    {
    case AR_VIDEO_1394_BRIGHTNESS:
        if (dc1394_feature_set_value(vid->camera, DC1394_FEATURE_BRIGHTNESS, (uint32_t)value) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set brightness to %d.\n", value);
            return -1;
        }

        return 0;

    case AR_VIDEO_1394_EXPOSURE:
        if (dc1394_feature_set_value(vid->camera, DC1394_FEATURE_EXPOSURE, (uint32_t)value) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set exposure to %d.\n", value);
            return -1;
        }

        return 0;

    case AR_VIDEO_1394_WHITE_BALANCE_UB:
        if (dc1394_feature_whitebalance_get_value(vid->camera, &ub, &vr) != DC1394_SUCCESS)
        {
            ARLOGe("unable to get white balance.\n");
            return -1;
        }

        if (dc1394_feature_whitebalance_set_value(vid->camera, (uint32_t)value, vr) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set white balance.\n");
            return -1;
        }

        return 0;

    case AR_VIDEO_1394_WHITE_BALANCE_VR:
        if (dc1394_feature_whitebalance_get_value(vid->camera, &ub, &vr) != DC1394_SUCCESS)
        {
            ARLOGe("unable to get white balance.\n");
            return -1;
        }

        if (dc1394_feature_whitebalance_set_value(vid->camera, ub, (uint32_t)value) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set white balance.\n");
            return -1;
        }

        return 0;

    case AR_VIDEO_1394_SHUTTER_SPEED:
        if (dc1394_feature_set_value(vid->camera, DC1394_FEATURE_SHUTTER, (uint32_t)value) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set shutter speed to %d.\n", value);
            return -1;
        }

        return 0;

    case AR_VIDEO_1394_GAIN:
        if (dc1394_feature_set_value(vid->camera, DC1394_FEATURE_GAIN, (uint32_t)value) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set gain to %d.\n", value);
            return -1;
        }

        return 0;

    case AR_VIDEO_1394_FOCUS:
        if (dc1394_feature_set_value(vid->camera, DC1394_FEATURE_FOCUS, (uint32_t)value) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set focus to %d.\n", value);
            return -1;
        }

        return 0;

    case AR_VIDEO_1394_GAMMA:
        if (dc1394_feature_set_value(vid->camera, DC1394_FEATURE_GAMMA, (uint32_t)value) != DC1394_SUCCESS)
        {
            ARLOGe("unable to set gamma to %d.\n", value);
            return -1;
        }

        return 0;
    }

    return -1;
}