Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] java – Android CameraX – manually change exposure compensation?

Posted on November 14, 2022

Solution 1 :

There is new version of CameraX library.

def camerax_version = '1.0.0-beta09'

Firstly add those dependencies to gradle file.

// CameraX core library
implementation "androidx.camera:camera-core:$camerax_version"

// CameraX Camera2 extensions
implementation "androidx.camera:camera-camera2:$camerax_version"

This version supports Exposure compensation which can be adjusted in runtime.
First create preview and takePicure use cases, and then bind those use cases to cameraProvider.

 camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture);

Now we have camera instance and it can be used to retrive CameraInfo, and from CameraInfo, we retrive ExposureState.

ExposureState exposureState = camera.getCameraInfo().getExposureState();

We can use exposureState to check if exposure compensation is supported on device

if (!exposureState.isExposureCompensationSupported()) return;

Next we need to get ExposureCompensation Range

Range<Integer> range = exposureState.getExposureCompensationRange();

Finally, we can set ExposureCompensation index in following way

 if (range.contains(index))
     camera.getCameraControl().setExposureCompensationIndex(index);

Solution 2 :

Looks like there is a Camera2Interop class under the CameraX API which allows you to internally change the values. This is the official documentation: Camera2Interop.Extender

Before building your ImageCapture, add this:

Camera2Interop.Extender(imageCaptureBuilder)
    .setCaptureRequestOption(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, value);

Solution 3 :

In case you want to know when the camera completed changing the exposure settings, do something like (camerax_version = ‘1.0.0’):

    lateinit var myCameraExposureListener: ListenableFuture<Int>

and then

        myCameraExposureListener =
        myCameraControl!!.setExposureCompensationIndex(exposureCompensationIndex);

    myCameraExposureListener.addListener({
        try {
            Log.v(TAG, "Changing Exposure Settings Completed")
        } catch (exception: Exception) {
            Log.v(TAG, "Changing Exposure Settings Failed")
        }
    }, ContextCompat.getMainExecutor(context) )

Problem :

I’m using CameraX for my project. I have created preview useCase and capture useCase.

final CameraSelector cameraSelector = new CameraSelector.Builder().requireLensFacing(lensFacing).build();

        previewBuilder = new Preview.Builder()
            .setTargetResolution(targetOutputSize)
            .setTargetRotation(rotation);

        preview = previewBuilder.build();

        final ImageCapture.Builder imageCaptureBuilder = new ImageCapture.Builder()
            .setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
            .setTargetResolution(targetOutputSize)
            .setTargetRotation(rotation);

        imageCapture = imageCaptureBuilder.build();

Everything works fine. Now, I need to add functionality to manually change exposure compensation, but I can’t find any reference in official documentation or anywhere else how to do this. Is it possible with CameraX, or I need to switch to Camera2 API?

READ  [ANSWERED] reactjs - react native android package repo (bintray)
Powered by Inline Related Posts

Please, any help is welcome.

Comments

Comment posted by Šemsudin Tafilović

It needs to be changeable during the use of camera. For example, on camera UI we need to have two buttons “+” and “-” and clicking on those buttons to change exposure compensation. Currently, this is not possible on CameraX, but I found that branch with this feature was merged into master on CameraX and I hope that it will be soon in release version.

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress