I have a custom Camera that works just fine,except for the implementation of flash that Iam using.I have tried using FLASH_MODE_AUTO
in surfaceChanged
.I have also tried using the following code using a Light Sensor
:
SensorEventListener listener=new SensorEventListener(){
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
//Not touching this with a ten foot pole
}
@Override
public void onSensorChanged(SensorEvent event) {
float lux=event.values[0];
Log.d(TAG, "The light sensor says: "+lux+" lux");
Camera.Parameters params=mCamera.getParameters();
cancelAutoFocus();
if(lux<50)
{
if(params.getFlashMode()!=Parameters.FLASH_MODE_ON)
params.setFlashMode(Parameters.FLASH_MODE_ON);
if(params.getExposureCompensation()!=params.getMinExposureCompensation())
params.setExposureCompensation(params.getMinExposureCompensation());
Log.d(TAG, "Exposure has been set to "+params.getMinExposureCompensation());
mCamera.setParameters(params);
}
else
{
params.setFlashMode(Parameters.FLASH_MODE_OFF);
mCamera.setParameters(params);
}
}
};
Whatever I do,when I take a picture and the flash fires,my picture ends up looking like this:
However when I take a picture with the default Camera app,it looks ordinary,even a little dim.
I would like to get rid of this workaround using the Light Sensor entirely and use FLASH_MODE_AUTO
.How can I get my camera to behave in low-light conditions and/or with the flash turned on?
Or is there any post-processing that I must do in order to ensure that the image is of lesser brightness.