예제 #1
0
        /// <summary>
        /// Query controls value from the video device.
        /// </summary>
        /// <param name="type">The type of a video device's control.</param>
        /// <returns>The default and current values of a video device's control.</returns>
        public override VideoDeviceValue GetVideoDeviceValue(VideoDeviceValueType type)
        {
            Initialize();

            // Get default value
            InteropVideodev2.v4l2_queryctrl query = new InteropVideodev2.v4l2_queryctrl
            {
                id = type
            };
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_QUERYCTRL, ref query);

            // Get current value
            InteropVideodev2.v4l2_control ctrl = new InteropVideodev2.v4l2_control
            {
                id = type,
            };
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_G_CTRL, ref ctrl);

            return(new VideoDeviceValue(
                       type.ToString(),
                       query.minimum,
                       query.maximum,
                       query.step,
                       query.default_value,
                       ctrl.value));
        }
예제 #2
0
        private unsafe void SetVideoConnectionSettings()
        {
            FillVideoConnectionSettings();

            // Set capture format
            InteropVideodev2.v4l2_format format = new InteropVideodev2.v4l2_format
            {
                type = InteropVideodev2.v4l2_buf_type.V4L2_BUF_TYPE_VIDEO_CAPTURE,
                fmt  = new InteropVideodev2.fmt
                {
                    pix = new InteropVideodev2.v4l2_pix_format
                    {
                        width       = Settings.CaptureSize.Width,
                        height      = Settings.CaptureSize.Height,
                        pixelformat = Settings.PixelFormat
                    }
                }
            };
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_FMT, ref format);

            // Set exposure type
            InteropVideodev2.v4l2_control ctrl = new InteropVideodev2.v4l2_control
            {
                id    = VideoDeviceValueType.ExposureType,
                value = (int)Settings.ExposureType
            };
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set exposure time
            // If exposure type is auto, this field is invalid
            ctrl.id    = VideoDeviceValueType.ExposureTime;
            ctrl.value = Settings.ExposureTime;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set brightness
            ctrl.id    = VideoDeviceValueType.Brightness;
            ctrl.value = Settings.Brightness;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set contrast
            ctrl.id    = VideoDeviceValueType.Contrast;
            ctrl.value = Settings.Contrast;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set saturation
            ctrl.id    = VideoDeviceValueType.Saturation;
            ctrl.value = Settings.Saturation;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set sharpness
            ctrl.id    = VideoDeviceValueType.Sharpness;
            ctrl.value = Settings.Sharpness;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set gain
            ctrl.id    = VideoDeviceValueType.Gain;
            ctrl.value = Settings.Gain;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set gamma
            ctrl.id    = VideoDeviceValueType.Gamma;
            ctrl.value = Settings.Gamma;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set power line frequency
            ctrl.id    = VideoDeviceValueType.PowerLineFrequency;
            ctrl.value = (int)Settings.PowerLineFrequency;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set white balance effect
            ctrl.id    = VideoDeviceValueType.WhiteBalanceEffect;
            ctrl.value = (int)Settings.WhiteBalanceEffect;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set white balance temperature
            ctrl.id    = VideoDeviceValueType.WhiteBalanceTemperature;
            ctrl.value = Settings.WhiteBalanceTemperature;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set color effect
            ctrl.id    = VideoDeviceValueType.ColorEffect;
            ctrl.value = (int)Settings.ColorEffect;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set scene mode
            ctrl.id    = VideoDeviceValueType.SceneMode;
            ctrl.value = (int)Settings.SceneMode;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set rotate
            ctrl.id    = VideoDeviceValueType.Rotate;
            ctrl.value = Settings.Rotate;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set horizontal flip
            ctrl.id    = VideoDeviceValueType.HorizontalFlip;
            ctrl.value = Settings.HorizontalFlip ? 1 : 0;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);

            // Set vertical flip
            ctrl.id    = VideoDeviceValueType.VerticalFlip;
            ctrl.value = Settings.VerticalFlip ? 1 : 0;
            V4l2Struct(InteropVideodev2.V4l2Request.VIDIOC_S_CTRL, ref ctrl);
        }