Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

update for import androidx.camera.core.ExposureCompensation;

42 views
Skip to first unread message
Assigned to wenhu...@google.com by me

S Chapman

unread,
Dec 5, 2024, 9:27:42 PM12/5/24
to Android CameraX Discussion Group
is there an update for this import, 'import androidx.camera.core.ExposureCompensation;'?

Wenhung Teng

unread,
Dec 24, 2024, 11:00:22 AM12/24/24
to Android CameraX Discussion Group, stephenl...@gmail.com
Hi,

Thanks for reaching out to the Android CameraX Discussion Group.
If you are using an older version of CameraX, you may need to update your code to use the new ExposureCompensation API.
To use the new API, you first need to get an instance of the CameraControl class. You can do this by calling the getCameraControl() method on your Camera object. Once you have a CameraControl object, you can use the setExposureCompensationIndex() method to set the exposure compensation value.  

The setExposureCompensationIndex() method takes an integer value as an argument. This value represents the exposure compensation index. The range of possible values for the exposure compensation index depends on the camera device. You can get the range of possible values by calling the getExposureCompensationRange() method on the CameraInfo object.  

Here is an example of how to use the ExposureCompensation API:
```
// Get a CameraControl instance
CameraControl cameraControl = camera.getCameraControl();

// Get the exposure compensation range
Range<Integer> range = camera.getCameraInfo().getExposureState().getExposureCompensationRange();

// Set the exposure compensation index
int index = 2;
if (range.contains(index)) {
  cameraControl.setExposureCompensationIndex(index);
}
```

If you have further questions or run into any issues, feel free to provide more context (like your CameraX version, code snippets, etc.) and we'll do our best to help!

stephenl...@gmail.com 在 2024年12月6日 星期五上午10:27:42 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages