首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows 8.1 MediaCapture预览聚焦速度较慢

Windows 8.1 MediaCapture预览聚焦速度较慢
EN

Stack Overflow用户
提问于 2015-08-28 05:35:17
回答 1查看 185关注 0票数 0

我正在使用MediaCapture实例展示Dell Venue 8专业版平板电脑摄像头的取景器。这款平板电脑运行的是Windows 8.1 Pro。我面临的问题是,相机在对焦和根据房间里的照明进行调整时似乎速度很慢。预览可以在太暗和太亮之间快速闪烁,似乎很难获得最佳的照明设置。使用股票相机应用程序没有问题的对焦。这是我用来初始化相机的代码。

代码语言:javascript
复制
// 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来解码二维码)

EN

回答 1

Stack Overflow用户

发布于 2015-09-01 00:32:26

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

代码语言:javascript
复制
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。官方CameraStarterKit sample建议按如下方式轮换预览,以提高效率:

代码语言:javascript
复制
// 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);

您可以通过//build/ presentation在摄影机会话中了解有关预览旋转的更多信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32259846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档