C# 如何在Windows Universal Apps中对焦摄像头?

C# 如何在Windows Universal Apps中对焦摄像头?,c#,camera,uwp,autofocus,C#,Camera,Uwp,Autofocus,我正在使用Windows通用OCR示例,该示例位于以下位置: 特别是OcrCapturedImage.xaml.cs 看起来,这款相机经常会变得不对焦、模糊,而且质量远不及原生相机应用程序。如何设置自动对焦和/或点击以固定曝光 到目前为止,我尝试的是查看其他有助于设置分辨率的相机样本,但我找不到任何关于焦距/曝光的信息 更新: 我想 await mediaCapture.VideoDeviceController.FocusControl.FocusAsync(); 及 但这是不起作用的(没

我正在使用Windows通用OCR示例,该示例位于以下位置:

特别是OcrCapturedImage.xaml.cs

看起来,这款相机经常会变得不对焦、模糊,而且质量远不及原生相机应用程序。如何设置自动对焦和/或点击以固定曝光

到目前为止,我尝试的是查看其他有助于设置分辨率的相机样本,但我找不到任何关于焦距/曝光的信息

更新:

我想

await mediaCapture.VideoDeviceController.FocusControl.FocusAsync();

但这是不起作用的(没有任何东西仍然模糊等),如果有人知道如何点击某个区域并相应地应用焦点/曝光,这可能会成为基础

本机摄像机:

应用程序摄像头:

根据答案更新:

我一定是把焦点方法放错地方了,因为我原来的更新代码可以工作。塞尔吉的也行。我想结合使用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
类的方法配置自动对焦

mediaCapture.VideoDeviceController.FocusControl.Configure(
    new FocusSettings { Mode = FocusMode.Auto });
await mediaCapture.VideoDeviceController.FocusControl.FocusAsync();
为了专注于某一领域,可以使用property。它具有添加实例集合的方法
RegionFinTerest
具有定义焦点区域的属性。此示例显示如何在中心设置焦点:

// 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) } 
         });

我在您链接的页面中没有看到
CapturedImage.cs
。您可以尝试,例如,
mediaCapture.VideoDeviceController.FocusControl.Configure(新的焦点设置{Mode=FocusMode.Auto})
然后调用
等待mediaCapture.VideoDeviceController.FocusControl.FocusAsync()@SergiiZhevzhyk您最后的建议有效。如果你能通过在预览屏幕上聚焦某一点来增加它,我将不胜感激。我的意思是,在本机相机上,你可以点击任何地方,焦距和曝光将设置为该区域。你可以尝试设置吗<代码>感兴趣区域选择计算焦距和曝光等功能的预览区域。这将启用诸如点击聚焦之类的场景。
@SergiiZhevzhyk是的,这些看起来是正确的。如果你把这两个都写下来,我会接受,我已经把你的答案标记为正确,但是有几件事可以补充,我已经在问题的更新中列出了。如果在时间框架结束时没有其他答案更好,我将奖励奖金。我通过在我的Roi中添加AutoFocusEnabled=true、AutoExposureEnabled=true、AutoWhiteBalanceEnabled=true、BoundsNomalized=true、Type=RegionFinterestType.Unknown和Weight=100,而不是仅仅添加边界,修复了参数错误。现在我的论点超出了范围。我的点数或尺码一定不正确
// 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) } 
         });