Ahmed Salman Tahir
Ahmed Salman Tahir

Reputation: 1777

Working with front camera (Xamarin.Android)

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

Upvotes: 0

Views: 3185

Answers (2)

Benoit Jadinon
Benoit Jadinon

Reputation: 1161

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;

Upvotes: 0

Ludwo
Ludwo

Reputation: 6193

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

Upvotes: 2

Related Questions