Esempio n. 1
0
// cvSetCaptureProperty callback function implementation
static int   
icvSetPropertyCAM_DC1394( CvCaptureCAM_DC1394* capture, int property_id, double value ){
	int index=-1;
	switch ( property_id ) {
		case CV_CAP_PROP_CONVERT_RGB:
			return icvSetConvertRGB( capture, value != 0 );
		case CV_CAP_PROP_MODE:
			return icvSetModeCAM_DC1394( capture, (int) value );
		case CV_CAP_PROP_FPS:
			return icvSetFrameRateCAM_DC1394( capture, value );
		case CV_CAP_PROP_BRIGHTNESS:
			index = FEATURE_BRIGHTNESS;
			break;
		case CV_CAP_PROP_CONTRAST: 
			index = FEATURE_GAMMA;
			break;
		case CV_CAP_PROP_SATURATION: 
			index = FEATURE_SATURATION;
			break;
		case CV_CAP_PROP_HUE:       
			index = FEATURE_HUE;
			break;
		case CV_CAP_PROP_GAIN:     
			index = FEATURE_GAIN;
			break;
		default:
			index = property_id;  // did they pass in a LIBDC1394 feature flag?
			break;
	}
	if(index>=FEATURE_MIN && index<=FEATURE_MAX){
		return icvSetFeatureCAM_DC1394(capture, index, (int) value);
	}
	return 0;
};
Esempio n. 2
0
// cvSetCaptureProperty callback function implementation
static int   
icvSetPropertyCAM_DC1394( CvCaptureCAM_DC1394* capture, int property_id, double value ){
  
_V_MW_  fprintf(stderr,"icvSetPropertyCAM_DC1394\n");
  
  int index=-1;
  switch ( property_id ) {
  case CV_CAP_PROP_CONVERT_RGB:
    return icvSetConvertRGB( capture, value != 0 );
  case CV_CAP_PROP_MODE:
    return icvSetModeCAM_DC1394( capture, (int) value );
  case CV_CAP_PROP_FPS:
    return icvSetFrameRateCAM_DC1394( capture, value );
  case CV_CAP_PROP_BRIGHTNESS:
    index = FEATURE_BRIGHTNESS;
    break;
  case CV_CAP_PROP_CONTRAST: 
    index = FEATURE_GAMMA;
    break;
  case CV_CAP_PROP_SATURATION: 
    index = FEATURE_SATURATION;
    break;
  case CV_CAP_PROP_HUE:       
    index = FEATURE_HUE;
    break;
  case CV_CAP_PROP_GAIN:     
    index = FEATURE_GAIN;
    break;
  default:
    index = property_id;  // did they pass in a LIBDC1394 feature flag?
    break;
  }

  if(value == -1) { // special case for setting AUTO
    if(index>=FEATURE_MIN && index<=FEATURE_MAX){
      return icvSetFeatureCAM_DC1394(capture, 
				     index, 
				     -1
				     );
    }
    else return -1;
  }
  else { // manual settings
  
    /* limitation of the input value */
    if (value < 0.0) {
      value = 0.0;
    } else if (value > 1.0) {
      value = 1.0;
    }

    unsigned int minval=0, maxval=0;
    if(dc1394_get_min_value(
  			    ((CvCaptureCAM_DC1394 *)capture)->handle,
  			    ((CvCaptureCAM_DC1394 *)capture)->camera->node,
			    index,
			    &minval) == DC1394_FAILURE){
      fprintf(stderr, "error getting min %d value\n", index);
      return -1;
    }
     
    if(dc1394_get_max_value(
		         ((CvCaptureCAM_DC1394 *)capture)->handle,
		         ((CvCaptureCAM_DC1394 *)capture)->camera->node,
		         index,
		         &maxval) == DC1394_FAILURE){
      fprintf(stderr, "error getting max %d value\n", index);
      return -1;
    }

    if(index>=FEATURE_MIN && index<=FEATURE_MAX){
      return icvSetFeatureCAM_DC1394(capture, 
				     index, 
				     (int)(value * (maxval - minval) + minval)
				     );
    }
    else return -1;
  }
}