/// <summary> /// Assigns the specified configuration to the media capture device. /// </summary> /// <param name="config">Configuration to set on media capture device.</param> public void SetDeviceConfiguration(MediaCaptureConfiguration config) { this.SetDeviceProperty(VideoProperty.BacklightCompensation, this.deviceInfo.BacklightCompensationInfo, config.BacklightCompensation); this.SetDeviceProperty(VideoProperty.Brightness, this.deviceInfo.BrightnessInfo, config.Brightness); this.SetDeviceProperty(VideoProperty.ColorEnable, this.deviceInfo.ColorEnableInfo, config.ColorEnable); this.SetDeviceProperty(VideoProperty.Contrast, this.deviceInfo.ContrastInfo, config.Contrast); this.SetDeviceProperty(VideoProperty.Gain, this.deviceInfo.GainInfo, config.Gain); this.SetDeviceProperty(VideoProperty.Gamma, this.deviceInfo.GammaInfo, config.Gamma); this.SetDeviceProperty(VideoProperty.Hue, this.deviceInfo.HueInfo, config.Hue); this.SetDeviceProperty(VideoProperty.Saturation, this.deviceInfo.SaturationInfo, config.Saturation); this.SetDeviceProperty(VideoProperty.Sharpness, this.deviceInfo.SharpnessInfo, config.Sharpness); this.SetDeviceProperty(VideoProperty.WhiteBalance, this.deviceInfo.WhiteBalanceInfo, config.WhiteBalance); this.SetDeviceProperty(ManagedCameraControlProperty.Focus, this.deviceInfo.FocusInfo, config.Focus); }
/// <summary> /// Initializes a new instance of the <see cref="MediaCapture"/> class. /// </summary> /// <param name="pipeline">Pipeline this component is a part of</param> /// <param name="width">Width of output image in pixels</param> /// <param name="height">Height of output image in pixels</param> /// <param name="deviceId">Device ID</param> /// <param name="pixelFormat">Pixel format</param> public MediaCapture(Pipeline pipeline, int width, int height, string deviceId = "/dev/video0", PixelFormatId pixelFormat = PixelFormatId.BGR24) : this(pipeline) { if (pixelFormat != PixelFormatId.BGR24 && pixelFormat != PixelFormatId.YUYV && pixelFormat != PixelFormatId.MJPEG) { throw new ArgumentException("Only YUYV and MJPEG are currently supported"); } this.configuration = new MediaCaptureConfiguration() { Width = width, Height = height, DeviceId = deviceId, PixelFormat = pixelFormat, }; }
/// <summary> /// Returns the current configuration for the media capture device /// </summary> /// <returns>A new MediaCaptureConfiguration object with the device's current settings</returns> public MediaCaptureConfiguration GetDeviceConfiguration() { MediaCaptureConfiguration config = new MediaCaptureConfiguration(); config.BacklightCompensation = this.GetValueBool(VideoProperty.BacklightCompensation, this.deviceInfo.BacklightCompensationInfo.Supported); config.Brightness = this.GetValueInt(VideoProperty.Brightness, this.deviceInfo.BrightnessInfo.Supported); config.ColorEnable = this.GetValueBool(VideoProperty.ColorEnable, this.deviceInfo.ColorEnableInfo.Supported); config.Contrast = this.GetValueInt(VideoProperty.Contrast, this.deviceInfo.ContrastInfo.Supported); config.Gain = this.GetValueInt(VideoProperty.Gain, this.deviceInfo.GainInfo.Supported); config.Gamma = this.GetValueInt(VideoProperty.Gamma, this.deviceInfo.GammaInfo.Supported); config.Hue = this.GetValueInt(VideoProperty.Hue, this.deviceInfo.HueInfo.Supported); config.Saturation = this.GetValueInt(VideoProperty.Saturation, this.deviceInfo.SaturationInfo.Supported); config.Sharpness = this.GetValueInt(VideoProperty.Sharpness, this.deviceInfo.SharpnessInfo.Supported); config.WhiteBalance = this.GetValueInt(VideoProperty.WhiteBalance, this.deviceInfo.WhiteBalanceInfo.Supported); config.Focus = this.GetValueInt(ManagedCameraControlProperty.Focus, this.deviceInfo.FocusInfo.Supported); return(config); }
/// <summary> /// Initializes a new instance of the <see cref="MediaCapture"/> class. /// </summary> /// <param name="pipeline">Pipeline this component is a part of.</param> /// <param name="width">Width of output image in pixels.</param> /// <param name="height">Height of output image in pixels.</param> /// <param name="framerate">Frame rate.</param> /// <param name="captureAudio">Should we create an audio capture device.</param> /// <param name="deviceId">Device ID.</param> /// <param name="useInSharedMode">Indicates whether camera is shared amongst multiple applications.</param> public MediaCapture(Pipeline pipeline, int width, int height, double framerate = 15, bool captureAudio = false, string deviceId = null, bool useInSharedMode = false) : this(pipeline) { this.configuration = new MediaCaptureConfiguration() { UseInSharedMode = useInSharedMode, DeviceId = deviceId, Width = width, Height = height, Framerate = framerate, CaptureAudio = captureAudio, }; if (this.configuration.CaptureAudio) { this.audio = new Audio.AudioCapture(pipeline, Psi.Audio.WaveFormat.Create16kHz1Channel16BitPcm()); } }
/// <summary> /// Initializes a new instance of the <see cref="MediaCapture"/> class. /// </summary> /// <param name="pipeline">Pipeline this component is a part of</param> /// <param name="configuration">Describes how to configure the media capture device</param> public MediaCapture(Pipeline pipeline, MediaCaptureConfiguration configuration) : this(pipeline) { this.configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="MediaCapture"/> class. /// </summary> /// <param name="pipeline">Pipeline this component is a part of</param> /// <param name="configurationFilename">Name of file containing media capture device configuration</param> public MediaCapture(Pipeline pipeline, string configurationFilename) : this(pipeline) { var configurationHelper = new ConfigurationHelper <MediaCaptureConfiguration>(configurationFilename); this.configuration = configurationHelper.Configuration; }
/// <summary> /// Initializes a new instance of the <see cref="MediaCapture"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">Describes how to configure the media capture device.</param> /// <param name="name">An optional name for the component.</param> public MediaCapture(Pipeline pipeline, MediaCaptureConfiguration configuration, string name = nameof(MediaCapture)) : this(pipeline, name) { this.configuration = configuration; }