3

I am building a viewfinder app using Android Camera2 api on Xamarin and I have a problem when preview is very dark.

My phone is LG G3, came2Basic app has similar behaviour except that after first picture has been taken the preview gets "normal" brightness and maintain it no matter how much light is it on scene (this is expected behaviour, that can be seen on a standart camera app).

Here is a code I use to start preview in my app:

        var surface = new Surface(texture);
        var builder = cameraDevice.CreateCaptureRequest(CameraTemplate.Preview);
        previewRequestBuilder.AddTarget(surface);

        var surfaces = new List<Surface> { surface };
        cameraDevice.CreateCaptureSession(surfaces, createCameraPreviewStateObservable, backgroundHandler);

        builder.Set(CaptureRequest.ControlMode, (int)ControlMode.Auto);
        var previewRequest = builder.Build();

        configured.Session.SetRepeatingRequest(
            previewRequest,
            cameraCatpureCallbackHandlerObservable,
            backgroundHandler);

I've seen similar questions (1, 2, 3, 4 and 5) but none of them has the solution workerd for me.

I assume there is some kind of process to obtain correct auto exposure parametes that I am missing.

So the question is: How to make Camera2 api to calculate correct exposure parameters?

Thanks.

Community
  • 1
  • 1
Dmitrii
  • 321
  • 6
  • 17
  • 1
    Possible duplicate http://stackoverflow.com/questions/26967490/android-camera-preview-is-dark http://stackoverflow.com/questions/31330098/android-surfaceview-preview-too-dark – Towfik Alrazihi Aug 31 '16 at 08:21
  • @gaurav4sarma same behavior on java version – Dmitrii Aug 31 '16 at 10:07
  • 1
    @TowfikAlrazihi links are in post, proposed solution doesn't affect app behavior on LG G3 – Dmitrii Aug 31 '16 at 10:09
  • The "duplicate" of this question is about the first camera API, this is about camera2. Quite a different scenario, not a duplicate. – Elte Hupkes Jul 17 '18 at 06:50

0 Answers0