VideoDeviceController.CameraOcclusionInfo Property

Definition

Gets a CameraOcclusionInfo object that can be used to get the current occlusion state of a camera and receive notifications when the occlusion state changes.

public:
 property CameraOcclusionInfo ^ CameraOcclusionInfo { CameraOcclusionInfo ^ get(); };
CameraOcclusionInfo CameraOcclusionInfo();
public CameraOcclusionInfo CameraOcclusionInfo { get; }
var cameraOcclusionInfo = videoDeviceController.cameraOcclusionInfo;
Public ReadOnly Property CameraOcclusionInfo As CameraOcclusionInfo

Property Value

CameraOcclusionInfo

The CameraOcclusionInfo for the capture device.

Windows requirements

Device family
Windows 11 (introduced in 10.0.22000.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v14.0)

Examples

The following example code illustrates the use of the CameraOcclusionInfo class to monitor the occlusion state of the camera.

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

    var occlusionInfo = mediaCapture.VideoDeviceController.CameraOcclusionInfo;
    occlusionInfo.StateChanged += CameraOcclusionInfo_StateChanged;

}

private void CameraOcclusionInfo_StateChanged(CameraOcclusionInfo sender, CameraOcclusionStateChangedEventArgs args)
{
    if (args.State.IsOccluded)
    {
        String occlusionString = "";
        if (args.State.IsOcclusionKind(CameraOcclusionKind.Lid))
        {
            occlusionString = "Lid";
        }
        else if (args.State.IsOcclusionKind(CameraOcclusionKind.CameraHardware))
        {
            occlusionString = "Camera Hardware";
        }
        else
        {
            occlusionString = "Unknown";
        }
        Debug.WriteLine(String.Format("The camera view is blocked by {0}", occlusionString);
    }
    else
    {
        Debug.WriteLine("Camera is not occluded");
    }
}

Remarks

You should only use the shutter state data obtained through this property while the camera is actively streaming. Apps should respond in a logical manner when they detect that the shutter is closed. This should include an in-app message to open the shutter. Applications must not automatically take an action (e.g., turning the camera off) or block the user from doing an action (e.g., turning on the camera) based on the shutter state, as not every camera will reliably report the shutter state when not streaming. Applications must not treat the reported shutter state as an absolute privacy indicator – it is only a notification that the camera believes the shutter is closed.

Applies to