Camera2basic应用程序,在Android 6.0 LGG3有非常黑暗的预览

新的API,也许只有LG G3,似乎有了一些变化。

我正在使用示例代码 。

在我的nexus 4,代码运行完美,但在LGG3更新到Android 6.0它不。 有任何想法吗?

我玩的设置,但没有运气,这仍然适用于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); 

Related of "Camera2basic应用程序,在Android 6.0 LGG3有非常黑暗的预览"

Camera2 API的FPS范围似乎使用了另一个比以前的Camera API更大的比例。 因此,如果您正在接收支持的预览fps范围(0,30000),则应该将值除以1000:

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

试试看是否有帮助,因为它有助于使用较旧的Camera API。

我find了适合我的解决scheme。 解决scheme是设置设备支持的FPS范围。

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

函数获取范围:

 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; } 

更新:其他设置(如果有人感兴趣)

 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);