Camera Windows 8.1 MediaCapture预览对焦速度慢

Camera Windows 8.1 MediaCapture预览对焦速度慢,camera,windows-8.1,tablet,Camera,Windows 8.1,Tablet,我正在使用MediaCapture实例显示Dell Vincement 8 Pro平板电脑摄像头的取景器。平板电脑运行的是Windows 8.1 Pro。我面临的问题是,相机在聚焦和根据室内光线进行调整时似乎很慢。预览会在太暗和太亮之间快速闪烁,似乎很难获得最佳照明设置。使用stock camera应用程序对焦没有问题。这是我用来初始化相机的代码 // Attempt to get the back camera if one is available, but use any camera d

我正在使用MediaCapture实例显示Dell Vincement 8 Pro平板电脑摄像头的取景器。平板电脑运行的是Windows 8.1 Pro。我面临的问题是,相机在聚焦和根据室内光线进行调整时似乎很慢。预览会在太暗和太亮之间快速闪烁,似乎很难获得最佳照明设置。使用stock camera应用程序对焦没有问题。这是我用来初始化相机的代码

// Attempt to get the back camera if one is available, but use any camera device if not
var cameraDevice = await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Back);
if (cameraDevice == null)
{
    Debug.WriteLine("No camera device found!");
    return;
}
var settings = new MediaCaptureInitializationSettings { 
    VideoDeviceId = cameraDevice.Id, 
    AudioDeviceId = "",
    StreamingCaptureMode = StreamingCaptureMode.Video, 
    PhotoCaptureSource = PhotoCaptureSource.VideoPreview
};
//setup media capture
mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(settings);
mediaCapture.VideoDeviceController.PrimaryUse = CaptureUse.Photo;
ViewFinder.Source = mediaCapture;
mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
await mediaCapture.StartPreviewAsync();

如何优化MediaCapture以快速聚焦?(应用程序需要MediaCapture来解码二维码)

听起来你想使用连续自动对焦。这段代码应该让您开始:

var focusControl = _mediaCapture.VideoDeviceController.FocusControl;

await focusControl.UnlockAsync();

// You may want to use AutoFocusRange.Macro for QR codes. Make sure it's within the supported modes though
var settings = new FocusSettings { Mode = FocusMode.Continuous, AutoFocusRange = AutoFocusRange.FullRange };

focusControl.Configure(settings);
await focusControl.FocusAsync();
另外,我注意到您正在使用SetPreviewRotation。为了提高效率,该官员建议按如下方式轮换预览:

// Rotation metadata to apply to the preview stream and recorded videos (MF_MT_VIDEO_ROTATION)
// Reference: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868174.aspx
readonly Guid RotationKey = new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");

// Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames
var props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);
props.Properties.Add(RotationKey, rotationDegrees);
await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, null);
您可以从中了解有关摄影机会话中预览旋转的更多信息