0

How can I lock my camera's autoExposure, whiteBalance and focus distance and then store their current settings and restore them at a later point?

The API only seems to lock the current state but does not allow to query the state let alone serialize it to restore it when the app is restarted. I can only query the state of the lock, but not the value itself.

My use case is computer vision where I want to configure the camera once and then always load the settings from the app's preferences.

Since I also have to support 4.4.x devices I am looking for a solution which would ideally work with all API > 4.4..

Camera.Parameters parameters = cameraView.getCameraParameters();
if (parameters == null) {
    return;
}
if (!parameters.isAutoExposureLockSupported()) {
    Log.w(TAG, "Device " + Devices.getModel() + " does not support exposure lock");
    return;
}
parameters.setAutoExposureLock(true);
Log.i(TAG, "Lock: " + parameters.getAutoExposureLock());
// getAutoExposureLock only returns true/false, not the exposure value itself
PhilLab
  • 4,777
  • 1
  • 25
  • 77
  • There is no universal way to achieve your goal, but on some devices you can read white balance and exposure with 'private' parameters. With camera2 API you may have better control, see e.g. http://stackoverflow.com/a/35886771/192373. – Alex Cohn May 18 '17 at 12:22
  • What about storing camera settings in a json file, and the reloading it everytime you start the app? if it sounds like you need let me know and i can give you a better idea – Jhonycage May 24 '17 at 17:33
  • you can switch depending on the API version and execute different methods or load different files – Jhonycage May 24 '17 at 17:35
  • @Juanca Of course, but the question is how to get the current white balance configuration and how to set it again? – PhilLab May 24 '17 at 18:43
  • 1
    please refer to this answer: https://stackoverflow.com/a/26104774/4910896 – Jhonycage May 24 '17 at 18:56

0 Answers0