Camera2basic app, has very dark preview in Android 6.0 LGG3

The new API, perhaps only on LG G3, seems to have something changed.

I'm using the sample code.

On my nexus 4, the code runs perfectly, but on LGG3 updated to Android 6.0 it does not. Any ideas?

I played with the settings, but no luck, this still works fine on Nexus 4:

mPreviewRequestBuilder.set(CaptureRequest.BLACK_LEVEL_LOCK, false);


mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AWB_LOCK, false);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);


mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, false);

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_ANTIBANDING_MODE, CaptureRequest.CONTROL_AE_ANTIBANDING_MODE_AUTO);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 0);
//mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, Range.create(1000,1000));
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, 0);


mPreviewRequestBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
mPreviewRequestBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_MODE_AUTO);


mPreviewRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT,
        CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW);

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
        CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);

FPS range for Camera2 API seems to use another scale than one for older Camera API. So, if you are receiving supported preview fps range (0, 30000), you should set the values divided by 1000:

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, Range.create(0, 30));

Try if this helps, as it helped with older Camera API.

Camera2basic app, has very dark preview in Android 6.0 LGG3, On my nexus 4, the code runs perfectly, but on LGG3 updated to Android 6.0 it does not. Any ideas? I played with the settings, but no luck, this still works fine on​  too - Camera2basic app, has very dark preview in Android 6.0 LGG3 google camera2 basic (2) The new API, perhaps only on LG G3, seems to have something changed.

I've found the solution that work for me. The solution is to setup FPS range that supported by device.

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, getRange());

Function to get range:

private Range<Integer> getRange() {
    CameraCharacteristics chars = mCameraManager.getCameraCharacteristics(mCameraId);
    Range<Integer>[] ranges = chars.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);

    Range<Integer> result = null;

    for (Range<Integer> range : ranges) {
        int upper = range.getUpper();

        // 10 - min range upper for my needs
        if (upper >= 10) {
            if (result == null || upper < result.getUpper().intValue()) {
                result = range;
            }
        }
    }

    if (result == null) {
        result = ranges[0];
    }

    return result;
}

Update: other settings (if someone interested in)

mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, false);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_AUTO);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
mPreviewRequestBuilder.set(CaptureRequest.STATISTICS_FACE_DETECT_MODE, CameraMetadata.STATISTICS_FACE_DETECT_MODE_SIMPLE);

Camera preview is very dark on API23. (maybe only on LG G3 , Новый API, возможно, только на LG G3, похоже, что-то изменилось. /​android-camera2basic-app-has-very-dark-preview-in-android-6-0-lgg3 – Lyubomir  This is frustrating because I know the cause of this bug, but I don't know of an adequate solution that's easy to implement. The problem is that for some reason the surface that's displaying the captured preview frames is acting as if the colors need to be converted from 'tv' ranges to 'full' ranges.

Setting the proper CONTROL_AE_TARGET_FPS_RANGE is the key.

There are few reasons why this can go wrong. As @Anton Malyshev said, some device gives you the CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES multiplied by 1000. So you must divide it by 1000 when setting CONTROL_AE_TARGET_FPS_RANGE.

Another reason I figured out is that the auto exposure fails for higher FPS depending on the resolution. So a simple workaround I did was to set the lower range to 0.

For example if the CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES has 24000:24000, then after dividing and setting the lower value to 0, the range would be 0:24

Camera2basic app, имеет очень темный предварительный , 0 LGG3 (2) The new API, perhaps only on LG G3, seems to have something syntax, for example too - Camera2basic app, has very dark preview in Android 6. Camera2basic app, has very dark preview in Android 6.0 LGG3 (2) The new API, perhaps only on LG G3, seems to have something changed. I'm using the sample code. On my nexus 4, the code runs perfectly, but on LGG3 updated to Android 6.0 it does not. Any ideas?

Xamarin detect dark mode, Is there an app where you can make a virtual touch button to screenshot capture on your 6587 Camera2basic app, has very dark preview in Android 6.0 LGG3. over 3 years how to pause preview? over 3 years Not capturing picture (ViewPostImeInputStage ACTION_DOWN) - Galaxy Tab4 10.1 3G; over 3 years Capturing with flash on Samsung S6 (6.0.1) causes the camera to become unresponsive. over 3 years Camera not re initialize second time in 5.1.1; over 3 years Camera preview is very dark on API23. (maybe

Is there a repo where you can download android virtual devices?, The #LGG3 is a great smartphone that's very powerful, but as Spider-Man's uncle might Camera2basic #app, has #very dark #preview in #Android 6.0 #LGG3  Front camera preview is very dark using camera2 api and it is really very dark when the environment is darker, but it is too dark if I compare it to the build-in Samsung camera

#LGG3, Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Comments
  • It would be better to ask this question here : android.stackexchange.com
  • They marked it as offtopic. :) android.stackexchange.com/questions/151735/…
  • Try this question and solutions: stackoverflow.com/questions/26967490/…
  • I tried them, did not manage to get it working.
  • @SmithThreeDee - did you have any luck with this??
  • I stopped working on it for now, I'm working on my core SLAM algorithm right now.
  • This did it for me! Thanks so much! To be clear, I combined the line above with mPreviewBuilder.set(CaptureRequest.CONTROL_AE_LOCK, false); and mPreviewBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);. Hope this helps anyone else who's been having issues with dark preview/images
  • in which state I can call this ?
  • before you call CameraManager.open()
  • @RomanBlack : thanks this worked for me in increasing the brightness of the camera view. However, my captured image still remains as it was. Please suggest.