android设备有红外灯时,一般在开启红外功能后,需要设置相机的颜色效果为黑白效果,对应的参考代码如下
- camera1参考代码
public void setCameraColorEffectMono(boolean mono) {
Camera.Parameters parameters = mCamera.getParameters();
parameters.setColorEffect(mono?Camera.Parameters.EFFECT_MONO:Camera.Parameters.EFFECT_NONE);
mCamera.setParameters(parameters);
}
- camera2参考代码
/**
* 黑白效果
*
* @param builder
* @param mono
*/
private void setupBuilderMono(CaptureRequest.Builder builder, boolean mono) {
if (null != builder) {
builder.set(CaptureRequest.CONTROL_EFFECT_MODE, mono ? CaptureRequest.CONTROL_EFFECT_MODE_MONO : CaptureRequest.CONTROL_EFFECT_MODE_OFF);
}
}