我正在使用MediaCapture实例展示Dell Venue 8专业版平板电脑摄像头的取景器。这款平板电脑运行的是Windows 8.1 Pro。我面临的问题是,相机在对焦和根据房间里的照明进行调整时似乎速度很慢。预览可以在太暗和太亮之间快速闪烁,似乎很难获得最佳的照明设置。使用股票相机应用程序没有问题的对焦。这是我用来初始化相机的代码。
// 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来解码二维码)
发布于 2015-09-01 00:32:26
听起来你想使用连续自动对焦。这段代码应该可以让您开始:
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建议按如下方式轮换预览,以提高效率:
// 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在摄影机会话中了解有关预览旋转的更多信息。
https://stackoverflow.com/questions/32259846
复制相似问题