簡體   English   中英

打開前臉攝像頭

[英]Open front face camera

我正在嘗試打開前置攝像頭,但它的開啟默認后置攝像頭。請告訴我如何實現這一目標?

CameraCaptureUI captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
StorageFile photo =await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);

if (photo == null)
{
    // User cancelled photo capture
    return;
}

您可以嘗試使用MediaCapture類而不是CameraCaptureUI: https ://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642092.aspx

您可以使用DeviceInformation類查詢可用的攝像頭,例如:

  DeviceInformation device = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture))
      .FirstOrDefault(d => d.EnclosureLocation != null && d.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front);

如果返回了設備,請在MediaCaptureInitializationSettings類中設置它的id:

MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings();
settings.VideoDeviceId = device.Id;

MediaCapture mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(settings);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM