Добрый день.
Такое ощущение что камера в моем приложении работает без автофокуса.
Вот так инициализирую камеру:
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
// Check to see if the camera is available on the device.
if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Front))
{
if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back))
{
System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions =
PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back);
Windows.Foundation.Size res = SupportedResolutions[5];
this.camera = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, res);
}
seq = camera.CreateCaptureSequence(1);
await camera.PrepareCaptureSequenceAsync(seq);
seq.Frames[0].DesiredProperties[KnownCameraPhotoProperties.SceneMode] = CameraSceneMode.Portrait;
seq.Frames[0].DesiredProperties[KnownCameraPhotoProperties.FlashMode] = FlashState.Off;
camera.SetProperty(KnownCameraGeneralProperties.PlayShutterSoundOnCapture, true);
camera.SetProperty(KnownCameraGeneralProperties.AutoFocusRange, AutoFocusRange.Full);
viewfinderBrush.SetSource(this.camera);
}
else
{
}
base.OnNavigatedTo(e);
}
Данный способ работы с камерой телефона показался мне самым быстрым. Быстрее всего инициализируется камера.
А вот так делаю фотографию:
private async void ApplicationBarIconButton_Click(object sender, EventArgs e)
{
MemoryStream captureStream1 = new MemoryStream();
seq.Frames[0].CaptureStream = captureStream1.AsOutputStream();
await seq.StartCaptureAsync();
BitmapImage bitmap = new BitmapImage();
captureStream1.Seek(0, SeekOrigin.Begin);
bitmap.SetSource(captureStream1);
}
Как правильно включить автофокус?