通过调整曝光解决
参考:https://blog.csdn.net/limingbocsdn/article/details/89176907
//设置预览请求的方式 previewBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); ... //自动对焦 previewBuilder.set(CaptureRequest.CONTROL_AF_MODE,CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); //设置自动曝光帧率范围 previewBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,getRange()); //对焦触发器设置为空闲状态 previewBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,CaptureRequest.CONTROL_AF_TRIGGER_IDLE); captureSession.setRepeatingRequest(previewBuilder.build(),captureCallback, mainHandler); private Range<Integer> getRange() { CameraManager mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); CameraCharacteristics chars = null; try { chars = mCameraManager.getCameraCharacteristics(cameraID); } catch (CameraAccessException e) { e.printStackTrace(); } Range<Integer>[] ranges = chars.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES); Range<Integer> result = null; for (Range<Integer> range : ranges) { //帧率不能太低,大于10 if (range.getLower()<10) continue; if (result==null) result = range; //FPS下限小于15,弱光时能保证足够曝光时间,提高亮度。range范围跨度越大越好,光源足够时FPS较高,预览更流畅,光源不够时FPS较低,亮度更好。 else if (range.getLower()<=15 && (range.getUpper()-range.getLower())>(result.getUpper()-result.getLower())) result = range; } return result; }