Working with front camera (Xamarin.Android)

自闭症网瘾萝莉.ら 提交于 2019-12-25 11:33:11

问题


I have gone through this recipe and it is working fine. However, I have a couple of questions:

1) It tells me how to work with the main camera but I am looking to work with the front camera, how can I do that?

2) I have to develop an app for 10.1 tablet and I was hoping that when I click on the 'Activate Camera' button, the front camera activates and rather than showing what the camera sees in the complete view, I should be able to show it in a defined box on that screen. In other words, I want to have a screen that has a button and a box in which I need to show what the camera sees. I believe I have seen an app do like this so I am assuming that it is doable.

Any help in these matters will be highly appreciated.

Thanks, Ahmed


回答1:


Try this sample. Maybe it is possible to setup Camera object somehow to use frontcam.




回答2:


how to get the front camera :

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;


来源:https://stackoverflow.com/questions/17298003/working-with-front-camera-xamarin-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!