我正在使用位于此处的 Windows 通用 OCR 示例:
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/OCR/cs
特别是 OcrCapturedImage.xaml.cs
相机似乎经常变得不对焦、模糊,并且远不及 native 相机应用程序的质量。如何设置自动对焦和/或点击以修复曝光?
到目前为止,我尝试过查看有助于设置分辨率的其他相机样本,但我找不到任何关于对焦/曝光的信息。
更新:
我觉得
await mediaCapture.VideoDeviceController.FocusControl.FocusAsync();
和
await mediaCapture.VideoDeviceController.ExposureControl.SetAutoAsync(true);
但这是行不通的(什么都不做 - 仍然模糊等),如果有人知道如何点击某个区域并相应地应用焦点/曝光,则可以在此基础上构建。
原生相机:
应用相机:
根据答案更新:
我一定是将焦点方法放在了错误的位置,因为我的原始更新代码有效。 Sergi 的也有效。我想结合使用点击事件,如下所示:
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
但是它抛出的参数不正确。另外,我如何在预览屏幕上显示一个矩形叠加层,以便用户知道感兴趣的区域有多大?
最佳答案
使用 Configure
配置自动对焦FocusControl
类的方法。
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) }
});
关于c# - 如何在 Windows 通用应用程序中对焦相机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34091390/