0

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:

Image obtained using my Camera under low-light conditions

However when I take a picture with the default Camera app,it looks ordinary,even a little dim.

Image obtained using the default Camera app

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.

vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
  • what is the problem with FLASH_MODE_AUTO? do you want to customize its implementation? – bofredo Nov 15 '13 at 13:47
  • I would like to use FLASH_MODE_AUTO but the photo I get has too much light,I took the first photo with minimum exposure and FLASH_MODE_ON using my app to get that picture.This workaround is because I dont want to set exposure to minimum in all cases.I just need to get a clear photo even if the flash fires.I wonder how the default camera and other Cameras get good photos with the flash turned on.Do they do any post-processing before they save it. – vamsiampolu Nov 16 '13 at 04:05
  • @bofredo do you have any solution,do you know anyone who has had a solution,I can post more code if nessecary. – vamsiampolu Nov 18 '13 at 05:32
  • no, not really. i once coded a photoburst and normally half of the photos taken are pretty bad. you can customize it for certain devices, but i dont know a general solution. – bofredo Nov 18 '13 at 10:12
  • I am using the Galaxy Nexus for testing,I have used apps like CamCard which have custom camera which use Flash to return a regular image...a little bit of excess light is okay,but this much is unacceptable,I take the image at close range... – vamsiampolu Nov 18 '13 at 10:30
  • i doubt that you can improve it. The phone is kind of antique and its not a reflex-camera. I am using the same device btw. – bofredo Nov 18 '13 at 10:44
  • So,if I take a camera with a different phone,say the S4,I will not get this issue. – vamsiampolu Nov 18 '13 at 11:33

0 Answers0