I'm writing a camera application that requires the same exposure regardless of ambient light. Unfortunately, setExposureCompensation() only acts like an offset. Can I turn off this auto adjustment, or is this more of a pre-user hardware correction?
EDIT: So, for Android 4.0 and above, there is a setAutoExposureLock(boolean) that should work for what you need. It doesn't let you set the exposure yourself, but after the exposure is determined, you can lock it into its current exposure. You need to guard it with a check for isAutoExposureLockSupported(), though, to make sure the device supports that feature.
To get the same actual exposure every time, you'd need to be able to set a fixed ISO, shutter speed, and aperture. As you said, the exposure compensation only offsets from the metered exposure, which the camera determines automatically. To my knowledge, there's no built in way to set the ISO, the shutter speed, or the aperture values in Android.
You should browse all your camera parameters to see if there are any related to ISO,shutter speed, and aperture.
Example:
Camera.Parameters params = mCamera.getParameters();
String sParams = params.flatten();
Log.d("TAG", "camera flatten: "+sParams);
Related
I am working on an app where I have a camera preview and I take pictures in dark settings. Therefore, I need a way to manually control the exposure time of the camera and the settings of shutter speed, aperture, and iso.
I know it must be possible because the application Long Exposure Camera 2 (by AAASDream) has a way to manually change the exposure time and it works perfectly. I am not referring to the exposurecompensation which I already tried but was not sufficient enough.
Based off of this post, I tried setting
Camera.Parameters params = camera1.getParameters();
params.set("mode", "m");
params.set("aperture", 80);
params.set("shutter-speed", 9);
params.set("iso", 1600);
But this did not work at all.
Is there any hidden API or setting that I can use or any third party library I can use to accomplish this.
All help is appreciated, thanks.
I think there is no way to manually set the above mentioned values in android.hardware.camera. But it looks like the new version android.hardware.camera2 supports those functionalities.
Yes, it isn't possible to manually set one of the two mentioned parameters directly via the Camera 1 API. Neither the characteristics can be queried via a standardized method, because it isn't supported.
Of course there is a way around, to query or to set such properties via special methods, as relime9 currently mentioned:
// query all the settings you camera support (API 1)
mCamera.getParameters().flatten();
// set parameters - e.g. aperture
mCamera.getParameters().set("aperture", "80");
Additionally the specific device must support such a setting, which vary from device to device. On some devices there can be set certain values and with other you can't and can only use the ''auto'' mode.
For this reason they developed the Camera 2 API, which is more standardized and supports such functionalities.
I'm playing with cwac-camera and it's a great library. I need to know if I can adjust the exposure compensation at real time when in preview mode. E.g.: is it possible to use the SeekBar in the CameraFragment demo to modify exposure instead of zoom level?
I succeeded saving picture with exposure compensation programmatically set at min or max level but I would like to be able to adjust before taking a picture.
I need to know if I can adjust the exposure compensation at real time when in preview mode
No. And to the extent that is possible today, it will not be possible in the future, as changing Camera.Parameters with a live preview seems to be a major source of my lingering device incompatibilities.
In android camera i am able to set the exposure compensation and lock the camera to minimum using the given methods
params = mCamera.getParameters();
params.setExposureCompensation(params.getMinExposureCompensation());
params.setAutoExposureLock(true);
but still this is not the minimum exposure. In the program i do it by pointing the camera to a bright light source and then lock the camera exposure on click of a button. This is however not a good method. Is there any other way to reduce the exposure to absolute minimum?
Latest update : Ios 8 supports better minimum exposure compensation
Both S5 and Nexus S use Qualcomm Snapdragon. You can find the code of its HAL in AOSP. You can modify this code to allow lower manual exposure levels. You don't even need to make changes on kernel level.
No, there is no easier way to do it - neither in Java nor using NDK.
I guess that using a torch the way you described it may be automated (let SW decide when to lock exposure, instead of a button), and will work for a wider range of devices, and don't need replacing system libraries.
I know how to get a lux value from the light sensor using android.hardware.sensor.
I saw light meter tools on the market. The application description said it can get the lux value from the camera. How can it do that?
Also how can I set the shutter speed and the aperture?
The android camera API doesn't provide any absolute units for the image data it captures. In addition, it does not allow for manual control of exposure or aperture (although essentially all cell phone cameras have no adjustable aperture anyway).
You can find out what exposure time used for a still capture from the JPEG EXIF, but that's about it.
Because of those limitations, you'll have a hard time getting an absolute light measurement from a captured camera image. You may be able to calibrate a given device to convert from image pixel value to true light level, but it'll be complicated since all devices run auto-exposure and auto-white-balance. Using auto-exposure and auto-white-balance locks introduced in Android 4.0 will help a bit, but there's still an unknown conversion curve between lux and a captured pixel value (not just a scale factor, it's a gamma curve).
Take a look at the Camera.Parameters class.
It has all functions supported by the Camera. Probably setExposureCompensation.
I don't know much about photography but my guess would be that exposure compensation is changing aperture or speed.
It could be that the tool you mentioned is using a bundled native library. Also have a look at how the functions given in Camera.Parameters class work (check android source code).
you can also use Ambient light sensor to get the light level in lux units (if this is within the scope of your project). From android documentation:
Sensor.TYPE_LIGHT:
values[0]: Ambient light level in SI lux units
Android Developer: Light Sensor-Sensor Event
You can find more information about the light sensor in the documentation.
Android Developer: Sensor
Agree, the trick is taking the picture and read its EXIF data.
You can find more about ExifInterface docs
http://developer.android.com/reference/android/media/ExifInterface.html
Depending iso and aperture values, then you can calculate the shuyy
I have written a camera app in android and I have tested it on two android phones, on one phone the auto-exposure works well when previewing but on the other phone it doesn't work at all. The first phone only works when I call the autoFocus() method. On the latter phone, the build-in app's auto-exposure works but not my code. Is there any method that can start use the auto-exposure manually?
Check Camera class
Camera.Parameters getParameters()
and check these two methods in Camera.Parameters class
int getExposureCompensation()
Gets the current exposure compensation index.
float getExposureCompensationStep()
Gets the exposure compensation step.
You should check the capabilities of camera of the phone before assuming existence of certain function