相机preVIEW是在低光照的Android太暗
我的相机应用preVIEW是在低光太暗。如果我打开我的谷歌相机会增加preVIEW内的亮度,使我们的脸是可见的拍照。但我的preVIEW已经完全黑了。我已经处理了亮度和lightsensor。我Lightsensor工作时,一些光。我需要preVIEW可见。让我我应该要处理?
My camera app preview is too dark in low light. If I open my google camera it will increase brightness inside the preview so that our face is visible to take photos. But my preview is completely dark. I have handled the brightness and lightsensor. My Lightsensor works when is some light. I need to make preview is visible. Let me what should I have to handle?
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);
}
我打电话相机preVIEW上课前在onCreate方法调用此方法。
I'm calling this method in onCreate method before camera preview class is called.
要解决你的问题的解锁autoExposureCompensation 和设置到最大值:
Camera.Parameters params = mCamera.getParameters();
params.setExposureCompensation(params.getMaxExposureCompensation());
if(params.isAutoExposureLockSupported()) {
params.setAutoExposureLock(false);
}
mCamera.setParameters(params);
据 Android的开发>参考> Camera.Parameters
改变白平衡模式setWhiteBalance(字符串),如果它被设置将发布自动白平衡锁定。
Changing the white balance mode with setWhiteBalance(String) will release the auto-white balance lock if it is set.
曝光补偿,AE锁定,和AWB锁可以用于捕捉图像的曝光括号突发,例如。自动白平衡状态,包括锁定状态,不会摄像机发布之后保持()被调用。
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.
锁定后打开自动白平衡(),但在第一次调用之前启动preVIEW()将不允许自动白平衡例程在所有运行,并可能导致在所拍摄的图像严重不正确的颜色。
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.
所以,要小心,并使用提到的code 后的第一个电话开始preVIEW()
So be careful and use the mentioned code after the first call to startPreview()