窗口 8 中的摄像头检测

本文关键字:摄像头 检测 窗口 | 更新日期: 2024-10-25 18:08:30

我正在Windows 8中开发一个应用程序,需要相机来捕获图片。那么我需要做什么才能知道相机是否存在(假设桌面没有网络摄像头,而 Windows 8 平板电脑有摄像头),所以我只需要显示控件以在设备上存在摄像头时显示摄像头。

窗口 8 中的摄像头检测

您需要使用此 API:.JS:

Windows.Devices.Enumeration.DeviceInformation.findAllAsync(Windows.Devices.Enumeration.DeviceClass.videoCapture).done(yourHandler);

C#:

var interfaces = await DeviceInformation.FindAllAsync(selector, null); 
foreach(DeviceInformation devInfo in interfaces) { /* stuff */ }

这包含有关此 API 其他方面的更多信息

由于使用的是 c#,因此此示例将更加具体。