InfraredTorchControl 类

定义

提供控制捕获设备上的红外火炬 LED 设置的功能。

public ref class InfraredTorchControl sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 524288)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class InfraredTorchControl final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 524288)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class InfraredTorchControl
Public NotInheritable Class InfraredTorchControl
继承
Object Platform::Object IInspectable InfraredTorchControl
属性

Windows 要求

设备系列
Windows 10, version 1903 (在 10.0.18362.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v8.0 中引入)

示例

using Windows.Media.Capture;

MediaCapture mediaCapture = new MediaCapture();

public MainPage()
{
    this.InitializeComponent();
}

protected override async void OnNavigatedTo(NavigationEventArgs e)
{
    await mediaCapture.InitializeAsync();

    // Preview is Windows.UI.Xaml.Controls.CaptureElement defined in XAML file
    // and used to render camera preview
    Preview.Source = mediaCapture;
    await mediaCapture.StartPreviewAsync();

    if (!TryIncrementInfraredPower())
    {
        Debug.WriteLine("Failed to increment InfraredTorch power");
    }
}

private bool TryIncrementInfraredPower()
{
    bool incrementSucceeded = false;

    if (mediaCapture.VideoDeviceController.InfraredTorchControl.IsSupported)
    {
        Debug.WriteLine("IR torch supported");
        InfraredTorchControl infraredTorchControl = mediaCapture.VideoDeviceController.InfraredTorchControl;
        var maxPower = infraredTorchControl.MaxPower;
        var powerStep = infraredTorchControl.PowerStep;
        var oldPower = infraredTorchControl.Power;

        if (oldPower < maxPower)
        {
            infraredTorchControl.Power = oldPower + powerStep;
            incrementSucceeded = true;
        }
        else
        {
            Debug.WriteLine("InfraredTorch is already at max power");
        }
    }

    return incrementSucceeded;
}

注解

InfraredTorchControl 使应用能够控制红外 LED 的电源和行为。

可以通过检查 InfraredTorchControl.IsSupported 来确定设备是否支持此控件。

可以通过 MediaCapture.VideoDeviceController 访问捕获设备的 InfraredTorchControl。

属性

CurrentMode

获取红外 LED 的当前操作模式。

IsSupported

获取一个值,该值指示捕获设备是否支持 InfraredTorchControl

MaxPower

获取捕获设备支持的最大红外 LED 功率值。

MinPower

获取捕获设备支持的最小红外 LED 功率值。

Power

获取或设置当前的红外 LED 功率值。

PowerStep

获取支持的电源步长值。

SupportedModes

SupportedModes 属性用于找出红外 LED 支持的模式。

适用于

另请参阅