通过调整曝光解决
参考:
参考:
//设置预览请求的方式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 RangegetRange() { CameraManager mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); CameraCharacteristics chars = null; try { chars = mCameraManager.getCameraCharacteristics(cameraID); } catch (CameraAccessException e) { e.printStackTrace(); } Range [] ranges = chars.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES); Range result = null; for (Range 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; }
posted on 2019-06-04 17:02 阅读( ...) 评论( ...) 收藏