【问题标题】:How to get the built in Camera if more than one cameras are connected?如果连接了多个摄像头,如何获取内置摄像头?
【发布时间】:2015-12-05 15:35:01
【问题描述】:

在通用 Windows 应用中使用以下代码 sn-p

var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);

if (devices.Count < 1)
{
     return;
}

string deviceID = devices[0].Id;

我可以获得连接到我的设备的相机。如果有多个摄像头,有没有办法明确获取内置摄像头而不是 USB(或蓝牙或其他任何东西)连接一个?

【问题讨论】:

标签: c# camera win-universal-app uwp


【解决方案1】:

使用EnclosureLocation.Panel property 确定您找到的摄像头是否是设备内置的摄像头。如果面板为Unknown,则为外接摄像头。请注意,可以有多个内置摄像头。 (例如,某些设备同时具有前置摄像头和后置摄像头。)

the Camera Starter Kit sample启发的代码:

// Attempt to get the back camera if one is available,
// but use any camera device if not.
var cameraDevice = await FindCameraDeviceByPanelAsync(
                             Windows.Devices.Enumeration.Panel.Back); 

if (cameraDevice == null)
{
    // This device has no camera.
}
else if (cameraDevice.EnclosureLocation == null ||
         cameraDevice.EnclosureLocation.Panel ==
                             Windows.Devices.Enumeration.Panel.Unknown) 
{ 
     // We have an external camera.
}
else
{
     // We have a built-in camera. The location is reported in
     // cameraDevice.EnclosureLocation.Panel.
}

【讨论】:

    猜你喜欢
    • 2013-05-13
    • 1970-01-01
    • 1970-01-01
    • 2016-03-06
    • 2021-08-08
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    • 2012-07-14
    相关资源
    最近更新 更多