2

I'm developing an App that uses Surfaceview. I can take pictures and everything's fine.

My problem is: the image of the preview is too dark. I try to change the SceneMode of the camera, but nothing is working (I've tried AUTO, NIGHT and NIGHT_PORTRAIT).

Here is the difference between pictures taken with my app:My App Camera

and the Android Camera App (native):enter image description here

Here's my code (the params used on cam):

        c = Camera.open(0);
        Camera.Parameters params =  c.getParameters();
        params.setSceneMode(Camera.Parameters.SCENE_MODE_NIGHT);
        params.setAutoExposureLock(true);
        params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
        if (params.getMaxNumMeteringAreas() > 0){ // check that metering areas are supported
            List<Camera.Area> meteringAreas = new ArrayList<>();
            Rect areaRect1 = new Rect(-100, -100, 100, 100);    // specify an area in center of image
            meteringAreas.add(new Camera.Area(areaRect1, 600)); // set weight to 60%
            Rect areaRect2 = new Rect(800, -1000, 1000, -800);  // specify an area in upper right of image
            meteringAreas.add(new Camera.Area(areaRect2, 400)); // set weight to 40%
            params.setMeteringAreas(meteringAreas);
        }
        c.setParameters(params);

Anyone can help me?

Thanks!

Community
  • 1
  • 1
Elvis Oliveira
  • 941
  • 2
  • 15
  • 29
  • 1
    Duplicate of http://stackoverflow.com/questions/26967490/android-camera-preview-is-dark ? – fadden Jul 09 '15 at 23:59
  • Thanks @fadden, I didnt find it on stack. – Elvis Oliveira Jul 10 '15 at 00:19
  • 1
    Such situations happen; they may be severely specific to device model, or if you are luckier, to sensor or chipset. Note that comparison to preinstalled Camera app is not fair: the latter has been optimized for one specific device (and even ROM version). – Alex Cohn Jul 12 '15 at 10:15

1 Answers1

2
  1. Don't lock auto-exposure; if you do, the camera is stuck with whatever settings it had when you locked it, which may be too dark

  2. Make sure the preview FPS range allows the camera to slow down frame rate in order to increase exposure. Best to select something like 10-30 fps as the range; see what the supported fps ranges are.

  3. Avoid setting the metering area until you have the rest of this working.

  4. The Android camera app is definitely not using NIGHT scene mode, so I would avoid it unless you know it does something useful on the device you're using your app on; it's not standardized across devices.

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47