gpt4 book ai didi

android - 相机预览在低光 android 中太暗

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:38:04 24 4
gpt4 key购买 nike

我的相机应用程序预览在低光下太暗。如果我打开我的谷歌相机,它会增加预览中的亮度,这样我们的脸就可以看到拍照了。但是我的预览是完全黑暗的。我已经处理了亮度和光传感器。我的光传感器在光线充足时工作。我需要使预览可见。让我有什么需要处理的?

 public void initialBrightness() {
try {
brightnessMode = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
brightnessModeAuto = true;
}
Settings.System.putInt(this.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 95);
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100;
getWindow().setAttributes(lp);

}

我在调用相机预览类之前在 onCreate 方法中调用此方法。

最佳答案

要解决此问题,您必须解锁自动曝光补偿设置为最大值:

Camera.Parameters params = mCamera.getParameters();

params.setExposureCompensation(params.getMaxExposureCompensation());

if(params.isAutoExposureLockSupported()) {
params.setAutoExposureLock(false);
}

mCamera.setParameters(params);

根据 Android Develop > Reference > Camera.Parameters

Changing the white balance mode with setWhiteBalance(String) will release the auto-white balance lock if it is set.

Exposure compensation, AE lock, and AWB lock can be used to capture an exposure-bracketed burst of images, for example. Auto-white balance state, including the lock state, will not be maintained after camera release() is called.

Locking auto-white balance after open() but before the first call to startPreview() will not allow the auto-white balance routine to run at all, and may result in severely incorrect color in captured images.

所以要小心,在第一次调用 startPreview() 之后使用提到的代码

关于android - 相机预览在低光 android 中太暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28429071/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com