Esempio n. 1
0
        public CameraSettingsDto GetCameraSettings()
        {
            CameraSettingsDto settings = null;
            if (!File.Exists("CameraPhotoSettings.xml"))
            {
                settings = new CameraSettingsDto
                {
                    SelectedAeMode = SDKData.Enums.AEMode.Manual,
                    SelectedAvValue = SDKData.Enums.ApertureValue.AV_8,
                    SelectedIsoSensitivity = SDKData.Enums.CameraISOSensitivity.ISO_400,
                    SelectedWhiteBalance = SDKData.Enums.WhiteBalance.Daylight,
                    SelectedShutterSpeed = SDKData.Enums.ShutterSpeed.TV_200,
                    SelectedCompensation = SDKData.Enums.ExposureCompensation.Zero
                };
                using (var file = File.Create("CameraPhotoSettings.xml"))
                {
                    new XmlSerializer(settings.GetType()).Serialize(file, settings);
                    file.Close();
                }

            }
            else {
                using (var file = File.OpenRead("CameraPhotoSettings.xml"))
                {
                    settings = (CameraSettingsDto)new XmlSerializer(typeof(CameraSettingsDto)).Deserialize(file);
                    file.Close();
                }
            }
            return settings;
        }
        public override void Initialize()
        {
            _imageProcessor.TimerElapsed += ImageProcessorOnTimerElapsed;
            _imageProcessor.CameraErrorEvent += ImageProcessorOnCameraErrorEvent;
            _imageProcessor.ImageChanged += ImageProcessorOnStreamChanged;
            _imageProcessor.ImageNumberChanged += ImageProcessorOnImageNumberChanged;


            _imageProcessor.InitializeProcessor();
            OpenSession();
            if (!_sessionOpened)
                return;

            _settings = _settingsProvider.GetCameraSettings();

            if (_settings != null)
            {
                _imageProcessor.SetSetting((uint)PropertyId.AEMode, (uint)_settings.SelectedAeMode);
                _imageProcessor.SetSetting((uint)PropertyId.WhiteBalance, (uint)_settings.SelectedWhiteBalance);
                _imageProcessor.SetSetting((uint)PropertyId.Av, (uint)_settings.SelectedAvValue);
                _imageProcessor.SetSetting((uint)PropertyId.ExposureCompensation, (uint)_settings.SelectedCompensation);
                _imageProcessor.SetSetting((uint)PropertyId.ISOSpeed, (uint)_settings.SelectedIsoSensitivity);
                _imageProcessor.SetSetting((uint)PropertyId.Tv, (uint)_settings.SelectedShutterSpeed);
            }
            _cameraStreamSynchronize = new AutoResetEvent(false);
            StartLiveView();
        }