public int GetBrightness() { int val; VideoProcAmpFlags flags; try { if (_videoSource.GetVideoProperty(VideoProcAmpProperty.Brightness, out val, out flags)) { return(val); } } catch { //ignore } return(-1); }
private static CameraProperty ReadProperty(VideoCaptureDevice device, VideoProcAmpProperty property) { CameraProperty p = new CameraProperty(); p.Identifier = property.ToString(); p.Specific = "VideoProcAmp"; p.ReadOnly = false; p.Type = CameraPropertyType.Integer; p.Representation = CameraPropertyRepresentation.LinearSlider; p.CanBeAutomatic = true; try { int min; int max; int step; int defaultValue; VideoProcAmpFlags flags; bool success = device.GetVideoPropertyRange(property, out min, out max, out step, out defaultValue, out flags); if (!success) { p.Supported = false; } else { p.Supported = true; p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); int currentValue; success = device.GetVideoProperty(property, out currentValue, out flags); if (!success) { p.Supported = false; } else { p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); p.Automatic = flags == VideoProcAmpFlags.Auto; } } } catch { p.Supported = false; } return(p); }
private VideoParm GetCameraParm() { var exposureValue = 0; //曝光-4 -10 var exposureFlage = CameraControlFlags.Auto; device.GetCameraProperty(CameraControlProperty.Exposure, out exposureValue, out exposureFlage); var brightnessValue = 0;//亮度 -64 64 var brightnessFlage = VideoProcAmpFlags.Auto; device.GetVideoProperty(VideoProcAmpProperty.Brightness, out brightnessValue, out brightnessFlage); var contrastValue = 0;//对比度 0 95 var contrastFlage = VideoProcAmpFlags.Auto; device.GetVideoProperty(VideoProcAmpProperty.Contrast, out contrastValue, out contrastFlage); var sharpnessValue = 0;//清晰度 1 7 var sharpnessFlage = VideoProcAmpFlags.Auto; device.GetVideoProperty(VideoProcAmpProperty.Sharpness, out sharpnessValue, out sharpnessFlage); var whiteBalanceValue = 0; //白平衡 var whiteBalanceFlage = VideoProcAmpFlags.Auto; device.GetVideoProperty(VideoProcAmpProperty.WhiteBalance, out whiteBalanceValue, out whiteBalanceFlage); var saturationValue = 0; //饱和度 var saturationFlage = VideoProcAmpFlags.Auto; device.GetVideoProperty(VideoProcAmpProperty.Saturation, out saturationValue, out saturationFlage); var gammaValue = 0; //伽马 var gammaFlage = VideoProcAmpFlags.Auto; device.GetVideoProperty(VideoProcAmpProperty.Gamma, out gammaValue, out gammaFlage); var backlightCompensationValue = 0; //逆光对比 var backlightCompensationFlage = VideoProcAmpFlags.Auto; device.GetVideoProperty(VideoProcAmpProperty.BacklightCompensation, out backlightCompensationValue, out backlightCompensationFlage); //var hueValue = 0; //色调 //var hueFlage = VideoProcAmpFlags.Auto; //device.GetVideoProperty(VideoProcAmpProperty.Hue, out hueValue, out hueFlage); VideoParm parm = new VideoParm { Baoguang = exposureValue, Liangdu = brightnessValue, Duibidu = contrastValue, Qingxidu = sharpnessValue, Baipingheng = whiteBalanceValue, Baohedu = saturationValue, Gama = gammaValue, Niguangduibi = backlightCompensationValue, //Sediao = hueValue }; return(parm); }