public async void InitializeAndGo() { Results = new ObservableCollection <Result>(); sensorLocation = CameraSensorLocation.Front; if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back)) { sensorLocation = CameraSensorLocation.Back; } PreviewResolution = GetBestPreviewResolution(sensorLocation); CaptureResolution = await GetBestCaptureResolution(sensorLocation, PreviewResolution); await InitializePhotoCaptureDevice(sensorLocation, CaptureResolution, PreviewResolution); await StartCapturingAsync(); _previewBuffer = new byte[(int)PreviewResolution.Width * (int)PreviewResolution.Height]; _rotatedPreviewBuffer = new byte[(int)PreviewResolution.Width * (int)PreviewResolution.Height]; _barcodeReader = new BarcodeReader(); PhotoCaptureDevice.PreviewFrameAvailable += PreviewFrame; stop = false; var focusingTask = new Task(Focusing); focusingTask.Start(); }
/// <summary> /// Initializes camera. Once initialized the instance is set to the /// DataContext.Device property for further usage from this or other /// pages. /// </summary> /// <param name="sensorLocation">Camera sensor to initialize.</param> private async Task InitializeCamera(CameraSensorLocation sensorLocation) { // Find out the largest capture resolution available on device IReadOnlyList <Size> availableResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); var captureResolution = new Windows.Foundation.Size(0, 0); foreach (Size t in availableResolutions) { if (captureResolution.Width < t.Width) { captureResolution = t; } } PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(sensorLocation, _defaultCameraResolution); await device.SetPreviewResolutionAsync(_defaultCameraResolution); await device.SetCaptureResolutionAsync(captureResolution); device.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, device.SensorLocation == CameraSensorLocation.Back ? device.SensorRotationInDegrees : -device.SensorRotationInDegrees); PhotoCaptureDevice = device; _isCameraInitialized = true; }
private async Task initCameraAsync(CameraSensorLocation sensorLocation) { if (cam != null) { cam.Dispose(); cam = null; } Windows.Foundation.Size res = new Windows.Foundation.Size(640, 480); cam = await PhotoCaptureDevice.OpenAsync(sensorLocation, res); await cam.SetPreviewResolutionAsync(res); viewfinder.SetSource(cam); viewfinderTransform.Rotation = sensorLocation == CameraSensorLocation.Back ? cam.SensorRotationInDegrees : -cam.SensorRotationInDegrees; imgFilterTransform.Rotation = sensorLocation == CameraSensorLocation.Back ? cam.SensorRotationInDegrees : -cam.SensorRotationInDegrees; // Vorbereitung für die Live s/w Vorschau bmp = new WriteableBitmap((int)cam.PreviewResolution.Width, (int)cam.PreviewResolution.Height); timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(10) }; timer.Tick += timer_Tick; timer.Start(); }
/// <summary> /// Initializes camera. Once initialized the instance is set to the /// DataContext.Device property for further usage from this or other /// pages. /// </summary> /// <param name="sensorLocation">Camera sensor to initialize.</param> private async Task InitializeCamera(CameraSensorLocation sensorLocation) { // Find out the largest capture resolution available on device IReadOnlyList <Windows.Foundation.Size> availableResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(0, 0); for (int i = 0; i < availableResolutions.Count; ++i) { if (captureResolution.Width < availableResolutions[i].Width) { Debug.WriteLine("MainPage.InitializeCamera(): New capture resolution: " + availableResolutions[i]); captureResolution = availableResolutions[i]; } } PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(sensorLocation, DefaultCameraResolution); await device.SetPreviewResolutionAsync(DefaultCameraResolution); await device.SetCaptureResolutionAsync(captureResolution); device.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, device.SensorLocation == CameraSensorLocation.Back ? device.SensorRotationInDegrees : -device.SensorRotationInDegrees); _dataContext.Device = device; }
private CameraSettings GetDefaultCameraSettings(CameraSensorLocation sensorLocation) { CameraSettings settings = new CameraSettings(); IReadOnlyList <FlashState> availableFlashStates = this.cameraEngine.GetAvailableFlashStates(sensorLocation); if (availableFlashStates.Count == 0) { settings.FlashState = FlashState.Off; } else if (availableFlashStates.Contains <FlashState>(FlashState.Auto)) { settings.FlashState = FlashState.Auto; } else { settings.FlashState = availableFlashStates[0]; } IReadOnlyList <Windows.Foundation.Size> availableCaptureResolutions = this.cameraEngine.GetAvailablePhotoCaptureResolutions(sensorLocation); // Pick the largest as a default // settings.CaptureResolution = availableCaptureResolutions[0]; return(settings); }
async private Task <PhotoCaptureDevice> OpenCamera(int width, int height, CameraSensorLocation loc) { var sizes = Helper.GetCameraSize(new Size(width, height), loc); PhotoCaptureDevice camera = await PhotoCaptureDevice.OpenAsync(loc, sizes["captureSize"]); await camera.SetPreviewResolutionAsync(sizes["previewSize"]); return(camera); }
private void CameraToggleButton_Click(object sender, System.Windows.RoutedEventArgs e) { SipService sipService = BackgroundProcessController.Instance.SipService; if (sipService != null) { CameraSensorLocation newCameraSensorLocation = (sipService.CameraLocation == CameraSensorLocation.Back) ? CameraSensorLocation.Front : CameraSensorLocation.Back; sipService.CameraLocation = newCameraSensorLocation; ((CallStatusViewModel)this.ViewModel).CameraLocation = newCameraSensorLocation; } }
public IReadOnlyList <FlashState> GetAvailableFlashStates(CameraSensorLocation cameraSensorLocation) { IReadOnlyList <object> rawValueList = PhotoCaptureDevice.GetSupportedPropertyValues(cameraSensorLocation, KnownCameraPhotoProperties.FlashMode); List <FlashState> flashStates = new List <FlashState>(rawValueList.Count); foreach (object rawValue in rawValueList) { flashStates.Add((FlashState)(uint)rawValue); } return(flashStates.AsReadOnly()); }
public IReadOnlyList<FlashState> GetAvailableFlashStates(CameraSensorLocation cameraSensorLocation) { IReadOnlyList<object> rawValueList = PhotoCaptureDevice.GetSupportedPropertyValues(cameraSensorLocation, KnownCameraPhotoProperties.FlashMode); List<FlashState> flashStates = new List<FlashState>(rawValueList.Count); foreach (object rawValue in rawValueList) { flashStates.Add((FlashState)(uint)rawValue); } return flashStates.AsReadOnly(); }
public static Nullable <UInt32> GetWhiteBalance(string wb, CameraSensorLocation loc) { var supportedPresets = PhotoCaptureDevice.GetSupportedPropertyValues(loc, KnownCameraPhotoProperties.WhiteBalancePreset); Nullable <UInt32> preset = null; if (wb.Equals("daylight", StringComparison.CurrentCultureIgnoreCase)) { preset = (UInt32)WhiteBalancePreset.Daylight; } return(preset.HasValue && supportedPresets.Contains(preset.Value) ? preset : null); }
// Gets the configuration of the specified camera private async Task <CameraConfig> GetCameraConfiguration( CameraType cameraType, CameraSensorLocation sensorLocation) { CameraConfig cameraConfig = null; PhotoCaptureDevice photoCaptureDevice = null; FlashState flash = FlashState.Off; List <CameraResolution> resolutions = new List <CameraResolution>(); try { // Read supported resolutions System.Collections.Generic.IReadOnlyList <Windows.Foundation.Size> SupportedResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); resolutions = (from resolution in SupportedResolutions select new CameraResolution { Width = resolution.Width, Height = resolution.Height }).ToList(); // Read flash support. // Opening camera is required to read flash, request to open with min resolution var minResolution = SupportedResolutions.OrderBy(size => size.Width).First(); photoCaptureDevice = await PhotoCaptureDevice.OpenAsync(sensorLocation, minResolution); Enum.TryParse <FlashState>( photoCaptureDevice.GetProperty(KnownCameraPhotoProperties.FlashMode).ToString(), true, out flash); // Create the camera config cameraConfig = new CameraConfig { Type = (int)cameraType, Sizes = resolutions, Flash = flash != FlashState.Off ? true : false }; } catch (Exception e) { Logger.Error("Error in Camera get configuration. Reason - " + e.Message); } finally { if (photoCaptureDevice != null) { try { photoCaptureDevice.Dispose(); } catch { } } } return(cameraConfig); }
/// <summary> /// Clicking on sensor button disables camera capturing controls, uninitializes old /// camera instance and initializes new camera instance using the other sensor. On-screen /// controls and listening to hardware shutter release key is disabled while initializing the /// sensor because capturing a photo is not possible at that time. /// </summary> private async void sensorButton_Click(object sender, EventArgs e) { FocusIndicator.SetValue(Canvas.VisibilityProperty, Visibility.Collapsed); _manuallyFocused = false; SetScreenButtonsEnabled(false); SetCameraButtonsEnabled(false); ShowProgress("Initializing camera..."); videoBrush.Opacity = 0.25; overlayComboBox.Opacity = 0; _dataContext.Device.Dispose(); _dataContext.Device = null; IReadOnlyList <CameraSensorLocation> sensorLocations = PhotoCaptureDevice.AvailableSensorLocations; if (_sensorLocation == sensorLocations[1]) { _sensorLocation = sensorLocations[0]; } else { _sensorLocation = sensorLocations[1]; } await InitializeCamera(_sensorLocation); videoBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = _dataContext.Device != null && _dataContext.Device.SensorLocation == CameraSensorLocation.Back ? _dataContext.Device.SensorRotationInDegrees : -_dataContext.Device.SensorRotationInDegrees }; videoBrush.SetSource(_dataContext.Device); videoBrush.Opacity = 1; overlayComboBox.Opacity = 1; HideProgress(); SetScreenButtonsEnabled(true); SetCameraButtonsEnabled(true); }
private async Task <Size> GetBestCaptureResolution(CameraSensorLocation sensorLocation, Size previewResolution) { // The last size in the AvailableCaptureResolutions is the lowest available var captureResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); var previewResolutions = PhotoCaptureDevice.GetAvailablePreviewResolutions(sensorLocation); Size resolution = await Task.Factory.StartNew(() => captureResolutions.LastOrDefault( c => (c.Width > 1000.0 || c.Height > 1000.0) && (c.Width / c.Height).Equals(previewResolution.Width / previewResolution.Height))); if (resolution == default(Size)) { return(previewResolution); } return(resolution); }
private Size GetBestPreviewResolution(CameraSensorLocation sensorLocation) { var previewResolutions = PhotoCaptureDevice.GetAvailablePreviewResolutions(sensorLocation); var result = new Size(640, 480); foreach (var previewResolution in previewResolutions) { if (previewResolution.Width * previewResolution.Height > result.Width * result.Height) { result = previewResolution; } } return(result); }
/// <summary> /// Initializes camera. /// </summary> /// <param name="sensorLocation">Camera sensor to initialize</param> private async Task InitializeCamera(CameraSensorLocation cameraSensorLocation) { Windows.Foundation.Size initialResolution = new Windows.Foundation.Size(Constant.DefaultCameraResolutionWidth, Constant.DefaultCameraResolutionHeight); Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(Constant.DefaultCameraResolutionWidth, Constant.DefaultCameraResolutionHeight); // Find out the largest 4:3 capture resolution available on device IReadOnlyList <Windows.Foundation.Size> availableResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(cameraSensorLocation); Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(0, 0); for (int i = 0; i < availableResolutions.Count; i++) { double ratio = availableResolutions[i].Width / availableResolutions[i].Height; if (ratio > 1.32 && ratio < 1.34) { if (captureResolution.Width < availableResolutions[i].Width) { captureResolution = availableResolutions[i]; } } } PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(cameraSensorLocation, initialResolution); await device.SetCaptureResolutionAsync(captureResolution); await device.SetPreviewResolutionAsync(previewResolution); _photoCaptureDevice = device; IReadOnlyList <object> supportedFlashmodes = PhotoCaptureDevice.GetSupportedPropertyValues(CameraSensorLocation.Back, KnownCameraPhotoProperties.FlashMode); if (supportedFlashmodes.Count > 1) { _photoCaptureDevice.SetProperty(KnownCameraPhotoProperties.FlashMode, FlashMode.Off); } else { TxtBlock_Flash.Visibility = Visibility.Collapsed; } SetOrientation(this.Orientation); }
private static Size GetPreviewSize(Size preferredSize, CameraSensorLocation loc) { IReadOnlyList <Size> previewSizes = PhotoCaptureDevice.GetAvailablePreviewResolutions(loc); Size selectedSize = Windows.Foundation.Size.Empty; foreach (Size size in previewSizes) { if (size.Equals(preferredSize)) { selectedSize = size; break; } } return(selectedSize.IsEmpty ? previewSizes[0] : selectedSize); }
public static UInt32 GetISO(UInt32 preferredISO, CameraSensorLocation loc) { CameraCapturePropertyRange isoRange = PhotoCaptureDevice.GetSupportedPropertyRange(loc, KnownCameraPhotoProperties.Iso); Nullable <UInt32> selectedISO = null; foreach (UInt32 standardISO in STANDARD_ISO_VALUES) { if (standardISO >= (UInt32)isoRange.Min && standardISO <= (UInt32)isoRange.Max && standardISO == preferredISO) { selectedISO = preferredISO; break; } } return(selectedISO.HasValue ? (UInt32)selectedISO : (UInt32)isoRange.Max); }
private static Size GetInitialResolution(CameraSensorLocation location, int videoWidth, int videoHeight) { var resolutions = AudioVideoCaptureDevice.GetAvailablePreviewResolutions(location); // find the closest resolution if (videoWidth > 0 || videoHeight > 0) { var closest = new List <Size>(); var distance = -1; foreach (var res in resolutions) { if (distance < 0) { closest.Add(res); distance = GetSizeDistance(res, videoWidth, videoHeight); } else { var d = GetSizeDistance(res, videoWidth, videoHeight); if (d == distance) { closest.Add(res); } else if (d < distance) { closest = new List <Size>(); closest.Add(res); distance = d; } } } resolutions = closest; } if (resolutions.Count == 0) { var error = "The camera does not support any resolutions."; Log.Error(error); throw new Exception(error); } return(resolutions[0]); }
public async Task <bool> LoadPhotoCamera(CameraSensorLocation cameraSensorLocation, Size captureResolution) { // If camera is already loaded, ignore the request // if (this.PhotoCaptureDevice != null) { return(false); } this.CameraSensorLocation = cameraSensorLocation; this.PhotoCaptureDevice = await PhotoCaptureDevice.OpenAsync(this.CameraSensorLocation, captureResolution); ApplyOrientation(); this.PhotoCaptureDevice.SetProperty(KnownCameraGeneralProperties.PlayShutterSoundOnCapture, true); return(true); }
private async Task initCameraAsync(CameraSensorLocation sensorLocation) { if (_cam != null) { _cam.Dispose(); _cam = null; } var res = new Windows.Foundation.Size(640, 480); _cam = await PhotoCaptureDevice.OpenAsync(sensorLocation, res); await _cam.SetPreviewResolutionAsync(res); viewfinder.SetSource(_cam); viewfinderTransform.Rotation = sensorLocation == CameraSensorLocation.Back ? _cam.SensorRotationInDegrees : -_cam.SensorRotationInDegrees; }
override internal void Update() { base.Update(); bool mediaActivated = false; bool callActived = false; bool videoActivated = false; SipAVCall avCall = null; SipHoldStateState holdState = SipHoldStateState.None; CameraSensorLocation cameraLocation = CameraSensorLocation.Front; SipService sipService = BackgroundProcessController.Instance.SipService; if (sipService != null) { avCall = sipService.SipActiveAVCall; } if (avCall != null) { mediaActivated = (avCall.State == SipAVCallState.InCall || avCall.State == SipAVCallState.EarlyMedia); callActived = (avCall.State != SipAVCallState.Terminated && avCall.State != SipAVCallState.Terminating); videoActivated = (mediaActivated && avCall.WithVideo); holdState = avCall.HoldState; cameraLocation = sipService.CameraLocation; } IsHangUpButtonEnabled = callActived; IsHoldButtonEnabled = mediaActivated; IsHoldButtonChecked = ((holdState & SipHoldStateState.LocalHeld) == SipHoldStateState.LocalHeld); IsCameraToggleButtonEnabled = videoActivated; LittleHeadVisibility = videoActivated ? Visibility.Visible : Visibility.Collapsed; LittleHeadPreviewUri = videoActivated ? (cameraLocation == CameraSensorLocation.Back ? rearFacingCameraStreamUri : frontFacingCameraStreamUri) : null; CameraLocation = cameraLocation; BigHeadVisibility = videoActivated ? Visibility.Visible : Visibility.Collapsed; BigHeadPreviewUri = videoActivated ? renderStreamUri : null; HoldState = holdState; UpdateAudioButtons(); }
private async Task InitializePhotoCaptureDevice(CameraSensorLocation sensorLocation, Size size, Size previewSize) { PhotoCaptureDevice = await PhotoCaptureDevice.OpenAsync(sensorLocation, size); await PhotoCaptureDevice.SetPreviewResolutionAsync(previewSize); CompositeTransform = new CompositeTransform(); CompositeTransform.CenterX = .5; CompositeTransform.CenterY = .5; CompositeTransform.Rotation = PhotoCaptureDevice.SensorRotationInDegrees - (Orientation == PageOrientation.LandscapeLeft ? 90 : 0) + (Orientation == PageOrientation.LandscapeRight ? 90 : 0); if (sensorLocation == CameraSensorLocation.Front) { CompositeTransform.ScaleX = -1; } VideoBrush = new VideoBrush(); VideoBrush.RelativeTransform = CompositeTransform; VideoBrush.Stretch = Stretch.Fill; VideoBrush.SetSource(PhotoCaptureDevice); }
private void SetDeviceProperties(CameraSensorLocation camera) { // try set Flash Mode to Off try { _device.SetProperty(KnownCameraPhotoProperties.FlashMode, FlashState.Off); } catch { Debug.Assert(false, "Off FlashMode not supported"); } // scene mode try { _device.SetProperty(KnownCameraPhotoProperties.SceneMode, CameraSceneMode.Macro); } catch { Debug.Assert(false, "Macro SceneMode not supported"); } }
/// <summary> /// Initializes camera. /// </summary> /// <param name="sensorLocation">Camera sensor to initialize</param> private async Task InitializeCamera(CameraSensorLocation sensorLocation) { Windows.Foundation.Size initialResolution = new Windows.Foundation.Size(DefaultCameraResolutionWidth, DefaultCameraResolutionHeight); Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(DefaultCameraResolutionWidth, DefaultCameraResolutionHeight); // Find out the largest 4:3 capture resolution available on device IReadOnlyList <Windows.Foundation.Size> availableResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(0, 0); for (int i = 0; i < availableResolutions.Count; i++) { double ratio = availableResolutions[i].Width / availableResolutions[i].Height; if (ratio > 1.32 && ratio < 1.34) { if (captureResolution.Width < availableResolutions[i].Width) { captureResolution = availableResolutions[i]; } } } PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(sensorLocation, initialResolution); await device.SetPreviewResolutionAsync(previewResolution); await device.SetCaptureResolutionAsync(captureResolution); _photoCaptureDevice = device; SetOrientation(this.Orientation); }
public async void InitializeAndGo() { Results = new ObservableCollection<Result>(); sensorLocation = CameraSensorLocation.Front; if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back)) sensorLocation = CameraSensorLocation.Back; PreviewResolution = GetBestPreviewResolution(sensorLocation); CaptureResolution = await GetBestCaptureResolution(sensorLocation, PreviewResolution); await InitializePhotoCaptureDevice(sensorLocation, CaptureResolution, PreviewResolution); await StartCapturingAsync(); _previewBuffer = new byte[(int)PreviewResolution.Width * (int)PreviewResolution.Height]; _rotatedPreviewBuffer = new byte[(int)PreviewResolution.Width * (int)PreviewResolution.Height]; _barcodeReader = new BarcodeReader(); PhotoCaptureDevice.PreviewFrameAvailable += PreviewFrame; stop = false; var focusingTask = new Task(Focusing); focusingTask.Start(); }
public static void TurnOnFlashlight(ToggleButton flashlight, AudioVideoCaptureDevice avDevice, CameraSensorLocation sensorLocation) { try { IReadOnlyList <object> supportedCameraModes = AudioVideoCaptureDevice.GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode); if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On)) { avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On); // set flash power to maxinum avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchPower, AudioVideoCaptureDevice.GetSupportedPropertyRange(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchPower).Max); } flashlight.IsChecked = true; } catch (Exception ex) { MessageBox.Show("Turn On Flashlight " + ex.Message); } }
private static Size GetInitialResolution(CameraSensorLocation location, int videoWidth, int videoHeight) { var resolutions = AudioVideoCaptureDevice.GetAvailablePreviewResolutions(location); // find the closest resolution if (videoWidth > 0 || videoHeight > 0) { var closest = new List<Size>(); var distance = -1; foreach (var res in resolutions) { if (distance < 0) { closest.Add(res); distance = GetSizeDistance(res, videoWidth, videoHeight); } else { var d = GetSizeDistance(res, videoWidth, videoHeight); if (d == distance) { closest.Add(res); } else if (d < distance) { closest = new List<Size>(); closest.Add(res); distance = d; } } } resolutions = closest; } if (resolutions.Count == 0) { var error = "The camera does not support any resolutions."; Log.Error(error); throw new Exception(error); } return resolutions[0]; }
public void LoadCamera(CameraSensorLocation cameraSensorLocation, Windows.Foundation.Size captureResolution) { EnqueueWorkflow(new LoadCameraWorkflow(this.callback, this.cameraController, cameraSensorLocation, captureResolution)); }
public IReadOnlyList<Size> GetAvailablePhotoCaptureResolutions(CameraSensorLocation cameraSensorLocation) { return this.cameraController.GetAvailablePhotoCaptureResolutions(cameraSensorLocation); }
public async Task<bool> LoadPhotoCamera(CameraSensorLocation cameraSensorLocation, Size captureResolution) { // If camera is already loaded, ignore the request // if (this.PhotoCaptureDevice != null) { return false; } this.CameraSensorLocation = cameraSensorLocation; this.PhotoCaptureDevice = await PhotoCaptureDevice.OpenAsync(this.CameraSensorLocation, captureResolution); ApplyOrientation(); this.PhotoCaptureDevice.SetProperty(KnownCameraGeneralProperties.PlayShutterSoundOnCapture, true); return true; }
public LoadCameraWorkflow(ICameraEngineEvents callback, CameraController cameraController, CameraSensorLocation cameraSensorLocation, Size captureResolution) : base(callback, cameraController) { this.cameraSensorLocation = cameraSensorLocation; this.captureResolution = captureResolution; }
/// <summary> /// Initializes camera. /// </summary> /// <param name="sensorLocation">Camera sensor to initialize</param> private async Task InitializeCamera(CameraSensorLocation sensorLocation) { Windows.Foundation.Size initialResolution = new Windows.Foundation.Size(FilterEffects.DataContext.DefaultPreviewResolutionWidth, FilterEffects.DataContext.DefaultPreviewResolutionHeight); Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(FilterEffects.DataContext.DefaultPreviewResolutionWidth, FilterEffects.DataContext.DefaultPreviewResolutionHeight); // Find out the largest 4:3 capture resolution available on device IReadOnlyList<Windows.Foundation.Size> availableResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(0, 0); for (int i = 0; i < availableResolutions.Count; i++) { double ratio = availableResolutions[i].Width / availableResolutions[i].Height; if (ratio > 1.32 && ratio < 1.34) { if (captureResolution.Width < availableResolutions[i].Width) { captureResolution = availableResolutions[i]; } } } PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(sensorLocation, initialResolution); await device.SetPreviewResolutionAsync(previewResolution); await device.SetCaptureResolutionAsync(captureResolution); _photoCaptureDevice = device; SetOrientation(this.Orientation); }
private static string GetCameraSensorLocationName(CameraSensorLocation location) { return Enum.GetName(location.GetType(), location); }
public IReadOnlyList <Size> GetAvailablePhotoCaptureResolutions(CameraSensorLocation cameraSensorLocation) { return(PhotoCaptureDevice.GetAvailableCaptureResolutions(cameraSensorLocation)); }
/// <summary> /// Initializes camera. /// </summary> /// <param name="sensorLocation">Camera sensor to initialize</param> private async Task InitializeCamera(CameraSensorLocation sensorLocation) { IReadOnlyList<Windows.Foundation.Size> availablePreviewResolutions = PhotoCaptureDevice.GetAvailablePreviewResolutions(sensorLocation); Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(int.MaxValue, int.MaxValue); for (int i = 0; i < availablePreviewResolutions.Count; i++) { double ratio = availablePreviewResolutions[i].Width / availablePreviewResolutions[i].Height; if (ratio > 1.32 && ratio < 1.34 && PerfectCamera.DataContext.Instance.CameraRatio == CameraRatio.Ratio_4x3) { if (previewResolution.Width > availablePreviewResolutions[i].Width) { previewResolution = availablePreviewResolutions[i]; } } else if (ratio > 1.7 && ratio < 1.8 && PerfectCamera.DataContext.Instance.CameraRatio == CameraRatio.Ratio_16x9) { if (previewResolution.Width > availablePreviewResolutions[i].Width) { previewResolution = availablePreviewResolutions[i]; } } } PerfectCamera.DataContext.Instance.PreviewResolution = previewResolution; IReadOnlyList<Windows.Foundation.Size> availableResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); //find 4:3 (2048 x 1536) or 16:9 (1280x720) Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(0, 0); for (int i = 0; i < availableResolutions.Count; i++) { double ratio = availableResolutions[i].Width / availableResolutions[i].Height; if (ratio > 1.32 && ratio < 1.34 && PerfectCamera.DataContext.Instance.CameraRatio == CameraRatio.Ratio_4x3) { if (captureResolution.Width < availableResolutions[i].Width) { captureResolution = availableResolutions[i]; } } else if (ratio > 1.7 && ratio < 1.8 && PerfectCamera.DataContext.Instance.CameraRatio == CameraRatio.Ratio_16x9) { if (captureResolution.Width < availableResolutions[i].Width) { captureResolution = availableResolutions[i]; } } } // PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(sensorLocation, captureResolution); await device.SetPreviewResolutionAsync(previewResolution); await device.SetCaptureResolutionAsync(captureResolution); Camera = device; if (PerfectCamera.DataContext.Instance.CameraType == PerfectCameraType.Selfie) { _cameraEffect = new Effects() { PhotoCaptureDevice = Camera }; _cameraStreamSource = new CameraStreamSource(_cameraEffect, previewResolution); } if (Camera != null) { if (Camera.SensorLocation == CameraSensorLocation.Front) { FlashButton.IsHitTestVisible = false; FlashButton.Opacity = 0.5; } else { FlashButton.IsHitTestVisible = true; FlashButton.Opacity = 1.0; } } SetOrientation(this.Orientation); }
public async Task InitializeCamera(CameraSensorLocation sensorLocation) { activeThreads = 0; isClosing = false; Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(1280, 720); Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(1280, 720); IReadOnlyList<Windows.Foundation.Size> prevSizes = PhotoCaptureDevice.GetAvailablePreviewResolutions(sensorLocation); IReadOnlyList<Windows.Foundation.Size> captSizes = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); double bestAspect = 1000; int bestAspectResIndex = 0; double aspect = Application.Current.Host.Content.ActualHeight / Application.Current.Host.Content.ActualWidth; for (int i = 0; i < captSizes.Count; i++) { double w = captSizes[i].Width; double h = captSizes[i].Height; double resAspect = w / h; double diff = aspect - resAspect; if (diff < 0) diff = -diff; if (diff < bestAspect) { bestAspect = diff; bestAspectResIndex = i; } } if (bestAspectResIndex >= 0) { captureResolution.Width = captSizes[bestAspectResIndex].Width; captureResolution.Height = captSizes[bestAspectResIndex].Height; } Windows.Foundation.Size initialResolution = captureResolution; try { PhotoCaptureDevice d = null; System.Diagnostics.Debug.WriteLine("Settinge camera initial resolution: " + initialResolution.Width + "x" + initialResolution.Height + "......"); bool initialized = false; try { d = await PhotoCaptureDevice.OpenAsync(sensorLocation, initialResolution); System.Diagnostics.Debug.WriteLine("Success " + initialResolution); initialized = true; captureResolution = initialResolution; } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Failed to set initial resolution: " + initialResolution + " error:" + e.Message); } if (!initialized) try { d = await PhotoCaptureDevice.OpenAsync(sensorLocation, captSizes.ElementAt<Windows.Foundation.Size>(0)); System.Diagnostics.Debug.WriteLine("Success " + captSizes.ElementAt<Windows.Foundation.Size>(0)); initialized = true; captureResolution = captSizes.ElementAt<Windows.Foundation.Size>(0); } catch { System.Diagnostics.Debug.WriteLine("Failed to set initial resolution: " + captSizes.ElementAt<Windows.Foundation.Size>(0)); } //try to not use too high resolution if (param_EnableHiRes) { MAX_RESOLUTION = 1280 * 800; } else { MAX_RESOLUTION = 800 * 480; } if (d.PreviewResolution.Height * d.PreviewResolution.Width > MAX_RESOLUTION) { bestAspectResIndex = -1; aspect = (double)captureResolution.Width / captureResolution.Height; for (int i = 0; i < prevSizes.Count; i++) { double w = prevSizes[i].Width; double h = prevSizes[i].Height; double resAspect = w / h; double diff = aspect - resAspect; if (diff < 0.01 && diff > -0.01) { if (w * h <= MAX_RESOLUTION) { previewResolution = prevSizes.ElementAt<Windows.Foundation.Size>(i); bestAspectResIndex = i; break; } } } if (bestAspectResIndex >= 0) try { await d.SetPreviewResolutionAsync(previewResolution); } finally { } } System.Diagnostics.Debug.WriteLine("Preview resolution: " + d.PreviewResolution); d.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, d.SensorLocation == CameraSensorLocation.Back ? d.SensorRotationInDegrees : -d.SensorRotationInDegrees); cameraDevice = d; cameraDevice.PreviewFrameAvailable += previewFrameHandler; IReadOnlyList<object> flashProperties = PhotoCaptureDevice.GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode); if (param_EnableFlash) { if (flashProperties.ToList().Contains((UInt32)VideoTorchMode.On)) { flashAvailable = true; if (param_DefaultFlashOn) { flashActive = true; cameraDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On); flashButtonImage.Source = new BitmapImage(new Uri("/Plugins/com.manateeworks.barcodescanner/flashbuttonon.png", UriKind.Relative)); } else { flashActive = false; cameraDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.Off); flashButtonImage.Source = new BitmapImage(new Uri("/Plugins/com.manateeworks.barcodescanner/flashbuttonoff.png", UriKind.Relative)); } flashButton.Visibility = System.Windows.Visibility.Visible; } else { flashAvailable = false; flashButton.Visibility = System.Windows.Visibility.Collapsed; } } else { flashButton.Visibility = System.Windows.Visibility.Collapsed; } videoBrush.SetSource(cameraDevice); focusTimer = new DispatcherTimer(); focusTimer.Interval = TimeSpan.FromSeconds(3); focusTimer.Tick += delegate { cameraDevice.FocusAsync(); }; focusTimer.Start(); } catch (Exception e) { Debug.WriteLine("Camera initialization error: " + e.Message); } }
private async Task initCamera(CameraSensorLocation sensorLocation) { Windows.Foundation.Size res = new Windows.Foundation.Size(MediaElementWidth, MediaElementHeight); CameraOff(); camera = await AudioVideoCaptureDevice.OpenForVideoOnlyAsync(sensorLocation, res); await camera.SetPreviewResolutionAsync(res); frameBitmap = new WriteableBitmap((int)camera.PreviewResolution.Width, (int)camera.PreviewResolution.Height); }
private async Task<Size> GetBestCaptureResolution(CameraSensorLocation sensorLocation, Size previewResolution) { // The last size in the AvailableCaptureResolutions is the lowest available var captureResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); var previewResolutions = PhotoCaptureDevice.GetAvailablePreviewResolutions(sensorLocation); Size resolution = await Task.Factory.StartNew(() => captureResolutions.LastOrDefault( c => (c.Width > 1000.0 || c.Height > 1000.0) && (c.Width / c.Height).Equals(previewResolution.Width / previewResolution.Height))); if (resolution == default(Size)) return previewResolution; return resolution; }
public static IDictionary <string, Size> GetCameraSize(Size preferredPreviewSize, CameraSensorLocation loc) { IReadOnlyList <Size> captureSizes = PhotoCaptureDevice.GetAvailableCaptureResolutions(loc); Size previewSize = GetPreviewSize(preferredPreviewSize, loc); // The aspect ratios of capture & preview resolutions have to match Size captureSize = captureSizes.Where(x => (x.Width * previewSize.Height == x.Height * previewSize.Width)).First(); Debug.WriteLine("Capture resolution: {0}x{1}", captureSize.Width, captureSize.Height); Debug.WriteLine("Preview resolution: {0}x{1}", previewSize.Width, previewSize.Height); return(new Dictionary <string, Size>() { { "previewSize", previewSize }, { "captureSize", captureSize } }); }
private async void ApplicationBarIconButton_Switch(object sender, EventArgs e) { if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Front)) { if (_cameraSemaphore.WaitOne(100)) { _cameraLocation = _cameraLocation == CameraSensorLocation.Back ? CameraSensorLocation.Front : CameraSensorLocation.Back; Uninitialize(); await Initialize(); _cameraSemaphore.Release(); } } }
/// <summary> /// Clicking on sensor button disables camera capturing controls, uninitializes old /// camera instance and initializes new camera instance using the other sensor. On-screen /// controls and listening to hardware shutter release key is disabled while initializing the /// sensor because capturing a photo is not possible at that time. /// </summary> private async void sensorButton_Click(object sender, EventArgs e) { FocusIndicator.SetValue(Canvas.VisibilityProperty, Visibility.Collapsed); _manuallyFocused = false; SetScreenButtonsEnabled(false); SetCameraButtonsEnabled(false); ShowProgress("Initializing camera..."); videoBrush.Opacity = 0.25; overlayComboBox.Opacity = 0; _dataContext.Device.Dispose(); _dataContext.Device = null; IReadOnlyList<CameraSensorLocation> sensorLocations = PhotoCaptureDevice.AvailableSensorLocations; if (_sensorLocation == sensorLocations[1]) { _sensorLocation = sensorLocations[0]; } else { _sensorLocation = sensorLocations[1]; } await InitializeCamera(_sensorLocation); videoBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = _dataContext.Device.SensorLocation == CameraSensorLocation.Back ? _dataContext.Device.SensorRotationInDegrees : - _dataContext.Device.SensorRotationInDegrees }; videoBrush.SetSource(_dataContext.Device); videoBrush.Opacity = 1; overlayComboBox.Opacity = 1; HideProgress(); SetScreenButtonsEnabled(true); SetCameraButtonsEnabled(true); }
async private Task <PhotoCaptureDevice> InitCamera(CameraPreviewSettings settings, CameraSensorLocation loc) { PhotoCaptureDevice camera = await OpenCamera(settings.Width, settings.Height, loc); UInt32 iso = Helper.GetISO((UInt32)settings.ISO, loc); Nullable <UInt32> wb = Helper.GetWhiteBalance(settings.WhiteBalance, loc); CameraCapturePropertyRange focusRange = PhotoCaptureDevice.GetSupportedPropertyRange(loc, KnownCameraGeneralProperties.ManualFocusPosition); UInt32 focusDistance = settings.FocusDistance.Equals("min", StringComparison.OrdinalIgnoreCase) ? (UInt32)focusRange.Min : (UInt32)focusRange.Max; camera.SetProperty(KnownCameraPhotoProperties.ExposureCompensation, 0); camera.SetProperty(KnownCameraPhotoProperties.FlashMode, FlashState.Off); camera.SetProperty(KnownCameraPhotoProperties.FocusIlluminationMode, 0); if (wb.HasValue) { camera.SetProperty(KnownCameraPhotoProperties.WhiteBalancePreset, wb.Value); _waitForWb = true; Debug.WriteLine("Using WB value: {0}", wb.Value); } camera.SetProperty(KnownCameraPhotoProperties.Iso, iso); camera.SetProperty(KnownCameraGeneralProperties.ManualFocusPosition, focusDistance); Debug.WriteLine("Using ISO: {0}, Using Focus Distance: {1}", camera.GetProperty(KnownCameraPhotoProperties.Iso), camera.GetProperty(KnownCameraGeneralProperties.ManualFocusPosition)); return(camera); }
private Size GetBestPreviewResolution(CameraSensorLocation sensorLocation) { var previewResolutions = PhotoCaptureDevice.GetAvailablePreviewResolutions(sensorLocation); var result = new Size(640, 480); foreach (var previewResolution in previewResolutions) { if (previewResolution.Width * previewResolution.Height > result.Width * result.Height) result = previewResolution; } return result; }
/// <summary> /// Initializes camera. Once initialized the instance is set to the /// DataContext.Device property for further usage from this or other /// pages. /// </summary> /// <param name="sensorLocation">Camera sensor to initialize.</param> private async Task InitializeCamera(CameraSensorLocation sensorLocation) { // Find out the largest capture resolution available on device IReadOnlyList<Windows.Foundation.Size> availableResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(0, 0); for (int i = 0; i < availableResolutions.Count; ++i) { if (captureResolution.Width < availableResolutions[i].Width) { Debug.WriteLine("MainPage.InitializeCamera(): New capture resolution: " + availableResolutions[i]); captureResolution = availableResolutions[i]; } } PhotoCaptureDevice device = await PhotoCaptureDevice.OpenAsync(sensorLocation, DefaultCameraResolution); await device.SetPreviewResolutionAsync(DefaultCameraResolution); await device.SetCaptureResolutionAsync(captureResolution); device.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, device.SensorLocation == CameraSensorLocation.Back ? device.SensorRotationInDegrees : -device.SensorRotationInDegrees); _dataContext.Device = device; }
private CameraSettings GetDefaultCameraSettings(CameraSensorLocation sensorLocation) { CameraSettings settings = new CameraSettings(); IReadOnlyList<FlashState> availableFlashStates = this.cameraEngine.GetAvailableFlashStates(sensorLocation); if (availableFlashStates.Count == 0) { settings.FlashState = FlashState.Off; } else if (availableFlashStates.Contains<FlashState>(FlashState.Auto)) { settings.FlashState = FlashState.Auto; } else { settings.FlashState = availableFlashStates[0]; } IReadOnlyList<Windows.Foundation.Size> availableCaptureResolutions = this.cameraEngine.GetAvailablePhotoCaptureResolutions(sensorLocation); // Pick the largest as a default // settings.CaptureResolution = availableCaptureResolutions[0]; return settings; }
public IReadOnlyList<FlashState> GetAvailableFlashStates(CameraSensorLocation cameraSensorLocation) { return this.cameraController.GetAvailableFlashStates(cameraSensorLocation); }
public IReadOnlyList <FlashState> GetAvailableFlashStates(CameraSensorLocation cameraSensorLocation) { return(this.cameraController.GetAvailableFlashStates(cameraSensorLocation)); }
public IReadOnlyList<Size> GetAvailablePhotoCaptureResolutions(CameraSensorLocation cameraSensorLocation) { return PhotoCaptureDevice.GetAvailableCaptureResolutions(cameraSensorLocation); }
public IReadOnlyList <Size> GetAvailablePhotoCaptureResolutions(CameraSensorLocation cameraSensorLocation) { return(this.cameraController.GetAvailablePhotoCaptureResolutions(cameraSensorLocation)); }
private async Task InitializeCamera(CameraSensorLocation sensorLocation) { activeThreads = 0; isClosing = false; Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(1280, 720); Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(1280, 720); IReadOnlyList <Windows.Foundation.Size> prevSizes = PhotoCaptureDevice.GetAvailablePreviewResolutions(sensorLocation); IReadOnlyList <Windows.Foundation.Size> captSizes = PhotoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation); double bestAspect = 1000; int bestAspectResIndex = 0; double aspect = Application.Current.Host.Content.ActualHeight / Application.Current.Host.Content.ActualWidth; for (int i = 0; i < captSizes.Count; i++) { double w = captSizes[i].Width; double h = captSizes[i].Height; double resAspect = w / h; double diff = aspect - resAspect; if (diff < 0) { diff = -diff; } if (diff < bestAspect) { bestAspect = diff; bestAspectResIndex = i; } } if (bestAspectResIndex >= 0) { captureResolution.Width = captSizes[bestAspectResIndex].Width; captureResolution.Height = captSizes[bestAspectResIndex].Height; } Windows.Foundation.Size initialResolution = captureResolution; try { PhotoCaptureDevice d = null; System.Diagnostics.Debug.WriteLine("Settinge camera initial resolution: " + initialResolution.Width + "x" + initialResolution.Height + "......"); bool initialized = false; try { d = await PhotoCaptureDevice.OpenAsync(sensorLocation, initialResolution); System.Diagnostics.Debug.WriteLine("Success " + initialResolution); initialized = true; captureResolution = initialResolution; } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Failed to set initial resolution: " + initialResolution + " error:" + e.Message); } if (!initialized) { try { d = await PhotoCaptureDevice.OpenAsync(sensorLocation, captSizes.ElementAt <Windows.Foundation.Size>(0)); System.Diagnostics.Debug.WriteLine("Success " + captSizes.ElementAt <Windows.Foundation.Size>(0)); initialized = true; captureResolution = captSizes.ElementAt <Windows.Foundation.Size>(0); } catch { System.Diagnostics.Debug.WriteLine("Failed to set initial resolution: " + captSizes.ElementAt <Windows.Foundation.Size>(0)); } } //try to not use too high resolution if (param_EnableHiRes) { MAX_RESOLUTION = 1280 * 800; } else { MAX_RESOLUTION = 800 * 480; } if (d.PreviewResolution.Height * d.PreviewResolution.Width > MAX_RESOLUTION) { bestAspectResIndex = -1; aspect = (double)captureResolution.Width / captureResolution.Height; for (int i = 0; i < prevSizes.Count; i++) { double w = prevSizes[i].Width; double h = prevSizes[i].Height; double resAspect = w / h; double diff = aspect - resAspect; if (diff < 0.01 && diff > -0.01) { if (w * h <= MAX_RESOLUTION) { previewResolution = prevSizes.ElementAt <Windows.Foundation.Size>(i); bestAspectResIndex = i; break; } } } if (bestAspectResIndex >= 0) { try { await d.SetPreviewResolutionAsync(previewResolution); } finally { } } } System.Diagnostics.Debug.WriteLine("Preview resolution: " + d.PreviewResolution); d.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, d.SensorLocation == CameraSensorLocation.Back ? d.SensorRotationInDegrees : -d.SensorRotationInDegrees); cameraDevice = d; cameraDevice.PreviewFrameAvailable += previewFrameHandler; IReadOnlyList <object> flashProperties = PhotoCaptureDevice.GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode); if (param_EnableFlash) { if (flashProperties.ToList().Contains((UInt32)VideoTorchMode.On)) { flashAvailable = true; if (param_DefaultFlashOn) { flashActive = true; cameraDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On); flashButtonImage.Source = new BitmapImage(new Uri("/Plugins/com.manateeworks.barcodescanner/flashbuttonon.png", UriKind.Relative)); } else { flashActive = false; cameraDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.Off); flashButtonImage.Source = new BitmapImage(new Uri("/Plugins/com.manateeworks.barcodescanner/flashbuttonoff.png", UriKind.Relative)); } flashButton.Visibility = System.Windows.Visibility.Visible; } else { flashAvailable = false; flashButton.Visibility = System.Windows.Visibility.Collapsed; } } else { flashButton.Visibility = System.Windows.Visibility.Collapsed; } videoBrush.SetSource(cameraDevice); focusTimer = new DispatcherTimer(); focusTimer.Interval = TimeSpan.FromSeconds(3); focusTimer.Tick += delegate { cameraDevice.FocusAsync(); }; focusTimer.Start(); } catch (Exception e) { Debug.WriteLine("Camera initialization error: " + e.Message); } }
private async void InitializeCameraAsync(CameraSensorLocation _sensor = CameraSensorLocation.Back) { SupportedResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(_sensor).ToList(); CurrentResolution = SupportedResolutions[0]; cam = await PhotoCaptureDevice.OpenAsync(_sensor, CurrentResolution); // Enable shutter sound cam.SetProperty(KnownCameraGeneralProperties.PlayShutterSoundOnCapture, true); // Create capture sequence seq = cam.CreateCaptureSequence(1); // White balance IReadOnlyList<object> wbList = PhotoCaptureDevice.GetSupportedPropertyValues(_sensor, KnownCameraPhotoProperties.WhiteBalancePreset); SupportedWhiteBalances = new List<object>(); SupportedWhiteBalances.Add(ProCamConstraints.PROCAM_AUTO_WHITE_BALANCE); foreach (object rawValue in wbList) { SupportedWhiteBalances.Add((WhiteBalancePreset)(uint)rawValue); } OSD.WhiteBalanceOSD.SupportedWhiteBalances = SupportedWhiteBalances; OSD.WhiteBalanceOSD.CurrentWhiteBalanceIndex = 0; // EV SupportedEVValues = new List<int>(); CameraCapturePropertyRange evRange = PhotoCaptureDevice.GetSupportedPropertyRange(_sensor, KnownCameraPhotoProperties.ExposureCompensation); int minEV = (int)evRange.Min; int maxEV = (int)evRange.Max; for (int i = minEV; i <= maxEV; i++) { SupportedEVValues.Add(i); } EVDialer.SupportedValues = SupportedEVValues; // ISO SupportedISOValues = new List<uint>(); SupportedISOValues.Add(ProCamConstraints.PROCAM_AUTO_ISO); CameraCapturePropertyRange isoRange = PhotoCaptureDevice.GetSupportedPropertyRange(_sensor, KnownCameraPhotoProperties.Iso); var minISO = (uint)isoRange.Min; var maxISO = (uint)isoRange.Max; foreach(var fixture in _supportedISOFixtures) { if(fixture >= minISO && fixture <= maxISO) { SupportedISOValues.Add(fixture); } } ISODialer.SupportedValues = SupportedISOValues; // Flash IReadOnlyList<object> flashList = PhotoCaptureDevice.GetSupportedPropertyValues(_sensor, KnownCameraPhotoProperties.FlashMode); SupportedFlashModes = new List<FlashState>(); foreach (object rawValue in flashList) { SupportedFlashModes.Add((FlashState)(uint)rawValue); } // Resolution OSD.MainOSD.SupportedResolutions = SupportedResolutions; OSD.MainOSD.CurrentResolution = CurrentResolution; // Scene modes SupportedSceneModes = new List<CameraSceneMode>(); IReadOnlyList<object> sceneList = PhotoCaptureDevice.GetSupportedPropertyValues(_sensor, KnownCameraPhotoProperties.SceneMode); foreach (object rawValue in sceneList) { SupportedSceneModes.Add((CameraSceneMode)(uint)rawValue); } OSD.SceneOSD.SupportedSceneModes = SupportedSceneModes; OSD.SceneOSD.CurrentIndex = 0; // Focus assist IReadOnlyList<object> focusList = PhotoCaptureDevice.GetSupportedPropertyValues(_sensor, KnownCameraPhotoProperties.FocusIlluminationMode); SupportedFocusAssistModes = new List<FocusIlluminationMode>(); foreach (object rawValue in focusList) { SupportedFocusAssistModes.Add((FocusIlluminationMode)(uint)rawValue); } OSD.FocusAssistOSD.SupportedModes = SupportedFocusAssistModes; OSD.FocusAssistOSD.CurrentIndex = 0; // Enable shutter sound cam.SetProperty(KnownCameraGeneralProperties.PlayShutterSoundOnCapture, true); // Create capture sequence seq = cam.CreateCaptureSequence(1); // Set video brush source ViewfinderBrush.SetSource(cam); CorrectViewfinderOrientation(Orientation); // Show UI chrome HideLoadingView(); // Events CameraButtons.ShutterKeyHalfPressed += OnShutterHalfPress; CameraButtons.ShutterKeyPressed += OnShutterFullPress; CameraButtons.ShutterKeyReleased += OnShutterReleased; }