Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camera2basic app, has very dark preview in Android 6.0 LGG3

Tags:

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); 
like image 728
Lyubomir Dinchev Avatar asked Jul 21 '16 00:07

Lyubomir Dinchev


1 Answers

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); 
like image 109
Roman Black Avatar answered Sep 24 '22 03:09

Roman Black