private void SetCameraSettings(AEMode aeMode, WhiteBalance balance, ApertureValue apertureValue, CameraISOSensitivity cameraIsoSensitivity, ShutterSpeed shutterSpeed) { //_imageProcessor.SetSetting((uint)PropertyId.AEMode, (uint)aeMode); TODO Не поддерживается Eos 1100 _imageProcessor.SetSetting((uint)PropertyId.WhiteBalance, (uint)balance); _imageProcessor.SetSetting((uint)PropertyId.Av, (uint)apertureValue); //_imageProcessor.SetSetting((uint)PropertyId.ExposureCompensation, (uint))); _imageProcessor.SetSetting((uint)PropertyId.ISOSpeed, (uint)cameraIsoSensitivity); _imageProcessor.SetSetting((uint)PropertyId.Tv, (uint)shutterSpeed); }
public virtual async Task<CompositionProcessingResult> TakePictureAsync(byte[] liveViewImageStream, AEMode selectedAeMode, ApertureValue selectedAvValue, CameraISOSensitivity selectedIsoSensitivity, ShutterSpeed selectedShutterSpeed, WhiteBalance selectedWhiteBalance, CancellationToken token) { Size liveViewImageStreamSize; using (var stream = new MemoryStream(liveViewImageStream)) { var img = Image.FromStream(stream); liveViewImageStreamSize = img.Size; } return new CompositionProcessingResult(_pattern, await TakePictureInternal(liveViewImageStreamSize, selectedAeMode, selectedAvValue, selectedIsoSensitivity, selectedShutterSpeed, selectedWhiteBalance, token)); }
private async Task<byte[]> Run(Size liveViewImageStreamSize, AEMode selectedAeMode, ApertureValue selectedAvValue, CameraISOSensitivity selectedIsoSensitivity, ShutterSpeed selectedShutterSpeed, WhiteBalance selectedWhiteBalance, CancellationToken token) { var settings = GetCameraPhotoSettings(); List<byte[]> pictures = new List<byte[]>(); for (int i = 0; i < _pattern.Images.Count; i++) { token.ThrowIfCancellationRequested(); RaiseImageNumberChanged(i + 1); RaiseTimerElapsed(4); await Task.Delay(TimeSpan.FromSeconds(2), token); for (int j = 3; j >= 0; j--) { RaiseTimerElapsed(j); await Task.Delay(TimeSpan.FromSeconds(1), token); } SetCameraSettings(Enum.Parse(typeof(AEMode), settings.SelectedAeMode), Enum.Parse(typeof(WhiteBalance), settings.SelectedWhiteBalance), Enum.Parse(typeof(ApertureValue), settings.SelectedAvValue), Enum.Parse(typeof(CameraISOSensitivity), settings.SelectedIsoSensitivity), Enum.Parse(typeof(ShutterSpeed), settings.SelectedShutterSpeed)); //await Task.Delay(TimeSpan.FromSeconds(1)); //RaiseImageNumberChanged(i + 1); // await Task.Delay(TimeSpan.FromSeconds(1), token); token.ThrowIfCancellationRequested(); byte[] picture = await _imageProcessor.DoTakePicture(); pictures.Add(picture); token.ThrowIfCancellationRequested(); // await Task.Delay(TimeSpan.FromSeconds(3), token); //todo SetCameraSettings(selectedAeMode, selectedWhiteBalance, selectedAvValue, selectedIsoSensitivity, selectedShutterSpeed); StopLiveView(); StartLiveView(); } byte[] result = _imageUtils.ProcessImages(pictures, liveViewImageStreamSize, _pattern); return result; }
protected async Task<byte[]> TakePictureInternal(Size liveViewImageStreamSize, AEMode selectedAeMode, ApertureValue selectedAvValue, CameraISOSensitivity selectedIsoSensitivity, ShutterSpeed selectedShutterSpeed, WhiteBalance selectedWhiteBalance, CancellationToken token) { return await Task.Run(() => Run(liveViewImageStreamSize, selectedAeMode, selectedAvValue, selectedIsoSensitivity, selectedShutterSpeed, selectedWhiteBalance, token), token); }
private void SetCameraSettings(AEMode aeMode, WhiteBalance balance, ApertureValue apertureValue, CameraISOSensitivity cameraIsoSensitivity, ShutterSpeed shutterSpeed) { _imageProcessor.SetSetting((uint)PropertyId.AEMode, (uint)aeMode); _imageProcessor.SetSetting((uint)PropertyId.WhiteBalance, (uint)balance); _imageProcessor.SetSetting((uint)PropertyId.Av, (uint)apertureValue); //_imageProcessor.SetSetting((uint)PropertyId.ExposureCompensation, (uint))); _imageProcessor.SetSetting((uint)PropertyId.ISOSpeed, (uint)cameraIsoSensitivity); _imageProcessor.SetSetting((uint)PropertyId.Tv, (uint)shutterSpeed); }
private async Task <byte[]> Run(Size liveViewImageStreamSize, AEMode selectedAeMode, ApertureValue selectedAvValue, CameraISOSensitivity selectedIsoSensitivity, ShutterSpeed selectedShutterSpeed, WhiteBalance selectedWhiteBalance, CancellationToken token) { var settings = GetCameraPhotoSettings(); var pictures = new List <byte[]>(); for (var i = 0; i < _pattern.Images.Count; i++) { token.ThrowIfCancellationRequested(); RaiseImageNumberChanged(i + 1); RaiseTimerElapsed(4); await Task.Delay(TimeSpan.FromSeconds(2), token); for (var j = 3; j >= 0; j--) { RaiseTimerElapsed(j); await Task.Delay(TimeSpan.FromSeconds(1), token); } SetCameraSettings(Enum.Parse(typeof(AEMode), settings.SelectedAeMode), Enum.Parse(typeof(WhiteBalance), settings.SelectedWhiteBalance), Enum.Parse(typeof(ApertureValue), settings.SelectedAvValue), Enum.Parse(typeof(CameraISOSensitivity), settings.SelectedIsoSensitivity), Enum.Parse(typeof(ShutterSpeed), settings.SelectedShutterSpeed)); //await Task.Delay(TimeSpan.FromSeconds(1)); //RaiseImageNumberChanged(i + 1); //await Task.Delay(TimeSpan.FromSeconds(1), token); token.ThrowIfCancellationRequested(); var picture = await _imageProcessor.DoTakePicture(); pictures.Add(picture); token.ThrowIfCancellationRequested(); //await Task.Delay(TimeSpan.FromSeconds(3), token); //todo SetCameraSettings(selectedAeMode, selectedWhiteBalance, selectedAvValue, selectedIsoSensitivity, selectedShutterSpeed); StopLiveView(); StartLiveView(); } var result = _imageUtils.ProcessImages(pictures, liveViewImageStreamSize, _pattern); return(result); }
protected async Task <byte[]> TakePictureInternal(Size liveViewImageStreamSize, AEMode selectedAeMode, ApertureValue selectedAvValue, CameraISOSensitivity selectedIsoSensitivity, ShutterSpeed selectedShutterSpeed, WhiteBalance selectedWhiteBalance, CancellationToken token) { return(await Task.Run(() => Run(liveViewImageStreamSize, selectedAeMode, selectedAvValue, selectedIsoSensitivity, selectedShutterSpeed, selectedWhiteBalance, token), token)); }
public virtual async Task <CompositionProcessingResult> TakePictureAsync(byte[] liveViewImageStream, AEMode selectedAeMode, ApertureValue selectedAvValue, CameraISOSensitivity selectedIsoSensitivity, ShutterSpeed selectedShutterSpeed, WhiteBalance selectedWhiteBalance, CancellationToken token) { Size liveViewImageStreamSize; using (var stream = new MemoryStream(liveViewImageStream)) { var img = Image.FromStream(stream); liveViewImageStreamSize = img.Size; } return(new CompositionProcessingResult(_pattern, await TakePictureInternal(liveViewImageStreamSize, selectedAeMode, selectedAvValue, selectedIsoSensitivity, selectedShutterSpeed, selectedWhiteBalance, token))); }