コード例 #1
0
ファイル: CameraStateManager.cs プロジェクト: MV10/spicam
        /// <summary>
        /// Camera settings (applies both config and hard-coded defaults).
        /// </summary>
        protected virtual void ConfigureCamera()
        {
            Console.WriteLine("Configuring camera.");

            MMALCameraConfig.Resolution = new Resolution(AppConfig.Get.Camera.Width, AppConfig.Get.Camera.Height);
            MMALCameraConfig.SensorMode = AppConfig.Get.Camera.Mode;
            MMALCameraConfig.Framerate  = AppConfig.Get.Camera.FPS;

            var overlay = new AnnotateImage(AppConfig.Get.Name, 30, Color.White)
            {
                ShowDateText = true,
                ShowTimeText = true,
                DateFormat   = "yyyy-MM-dd",
                TimeFormat   = "HH:mm:ss",
                RefreshRate  = DateTimeTextRefreshRate.Seconds
            };

            MMALCameraConfig.Annotate = overlay;

            // image quality tweaks to play with later
            MMALCameraConfig.Sharpness            = 0;  // 0 = auto, default; -100 to 100
            MMALCameraConfig.Contrast             = 0;  // 0 = auto, default; -100 to 100
            MMALCameraConfig.Brightness           = 50; // 50 = default; 0 = black, 100 = white
            MMALCameraConfig.Saturation           = 0;  // 0 = default; -100 to 100
            MMALCameraConfig.ExposureCompensation = 0;  // 0 = none, default; -10 to 10, lightens/darkens the image

            // low-light tweaks which don't seem to degrade full-light recording
            MMALCameraConfig.ExposureMode      = MMAL_PARAM_EXPOSUREMODE_T.MMAL_PARAM_EXPOSUREMODE_NIGHT;
            MMALCameraConfig.ExposureMeterMode = MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX;
            MMALCameraConfig.DrcLevel          = MMAL_PARAMETER_DRC_STRENGTH_T.MMAL_PARAMETER_DRC_STRENGTH_HIGH;

            // h.264 requires key frames for the circular buffer capture handler
            MMALCameraConfig.InlineHeaders = true;

            Cam.ConfigureCameraSettings();
            Cam.EnableAnnotation();
        }