簡體   English   中英

如何使用 xamarin android 打開前置攝像頭

[英]How can I open front camera using xamarin android

我想在我的應用程序中打開我的設備的前置攝像頭以進行面部驗證,標題為“相機微笑”。我該怎么做,目前我正在使用后置攝像頭默認值,如何更改為前置攝像頭以及隱藏后置攝像頭選項。

請幫我

這是我打開相機的代碼

  Intent intent = new Intent(MediaStore.ActionImageCapture);
  StartActivityForResult(intent, 0);

據我了解,您必須遍歷與相機標識符匹配的可用硬件設備。

這個SO 答案表明:

Camera.CameraInfo camInfo = new Camera.CameraInfo ();
for (int i = 0; i < Camera.NumberOfCameras; i++) {
    Camera.GetCameraInfo (i, camInfo);
    if (camInfo.Facing == CameraFacing.Front){
        try {
            return Camera.Open(i);
        } catch (Exception e) {
            // log or something
        }
    }
}
return null;

xamarin 論壇上也有一個關於此問題的問題,它似乎提供了類似的方法, 可以在此處找到。

暫無
暫無

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

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