[英]How do I Focus a Camera in Windows Universal Apps?
我正在使用位于此处的Windows Universal Sample for OCR:
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/OCR/cs
特别是OcrCapturedImage.xaml.cs
看起来相机经常变得没有焦点,模糊,并且远远不如原生相机应用程序那么好。 如何设置自动对焦和/或点按以修复曝光?
我到目前为止所看到的是查看其他有助于设置分辨率的相机样本,但我找不到有关焦距/曝光的任何信息。
更新:
我认为
await mediaCapture.VideoDeviceController.FocusControl.FocusAsync();
和
await mediaCapture.VideoDeviceController.ExposureControl.SetAutoAsync(true);
但是,如果有人知道如何挖掘某个区域并相应地应用焦点/曝光,那么这不起作用(不做任何事情 - 仍然模糊等)并且可以建立起来。
原生相机:
应用相机:
根据答案更新:
我一定是把我的焦点方法放在错误的位置,因为我的原始更新代码有效。 Sergi也有效。 我想将tapped事件与它结合使用,如下所示:
Point tapped=e.GetPosition(null); //Where e is TappedRoutedEventArgs from a tapped event method on my preview screen
await mediaCapture.VideoDeviceController.RegionsOfInterestControl.ClearRegionsAsync();
await mediaCapture.VideoDeviceController.RegionsOfInterestControl.SetRegionsAsync(new[] { new RegionOfInterest() { Bounds = new Rect(tapped.X, tapped.Y, 0.02, 0.02) } }); //Throws Parameter Incorrect
但它抛出参数不正确。 另外,如何在预览屏幕上显示矩形的矩形,以便用户知道感兴趣的区域有多大?
使用FocusControl
类的Configure
方法Configure
自动对焦。
mediaCapture.VideoDeviceController.FocusControl.Configure(
new FocusSettings { Mode = FocusMode.Auto });
await mediaCapture.VideoDeviceController.FocusControl.FocusAsync();
为了专注于某个区域,可以使用RegionOfInterestControl
。 它具有SetRegionsAsync
方法来添加RegionOfInterest
实例的集合。 RegionOfInterest
具有Bounds
属性,用于定义焦点区域。 此示例显示如何在中心设置焦点:
// clear previous regions of interest
await mediaCapture.VideoDeviceController.RegionOfInterestControl.ClearRegionsAsync();
// focus in the center of the screen
await mediaCapture.VideoDeviceController.RegionOfInterestControl.SetRegionsAsync(
new []
{
new RegionOfInterest() {Bounds = new Rect(0.49,0.49,0.02,0.02) }
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.