0

I have a CameraX-App and I'm trying to change the gamma value of the pictures I take. Since CameraX doesn't support that, I have to use the Camera2Interop class to use Camera2 functionality.

It should be relatively easy to change the gamma value and there is nothing to do wrong, but for some reason it's just not changing my gamma value. The Preview and pictures I take never change at all.

The relevant code is very simple:

    ImageCapture.Builder builder = new ImageCapture.Builder();
    Camera2Interop.Extender<ImageCapture> extender = new Camera2Interop.Extender<>(builder);
    extender.setCaptureRequestOption(CaptureRequest.TONEMAP_MODE, CaptureRequest.TONEMAP_MODE_GAMMA_VALUE);
    extender.setCaptureRequestOption(CaptureRequest.TONEMAP_GAMMA, 0.1f);
    ImageCapture imageCapture = builder.build();

I tried all types of float values for gamma but never noticed any change. I tried it with multiple devices (new and old devices) from multiple brands. Gamma never changed.

It works when i do:

extender.setCaptureRequestOption(CaptureRequest.TONEMAP_MODE, CameraMetadata.TONEMAP_MODE_CONTRAST_CURVE); extender.setCaptureRequestOption(CaptureRequest.TONEMAP_CURVE, tonemapCurve);

Or with other tonemap modes I've tried, but not gamma. It is very important that it works that way though. Does anyone have any ideas on how to make it work?

I've found a similar question to mine (I think) but unfortunately without answers: Android Camera2 API contrast/gamma is not working for video preview

I showed above what I tried and what I've expected.

Kaito Kid
  • 1
  • 1

1 Answers1

0

Have you verified those devices support TONEMAP_MODE_GAMMA_VALUE?

It's not guaranteed to be supported, and you need to check the list of supported tonemap modes before trying to use it: AVAILABLE_TONE_MAP_MODES

That said, if TONEMAP_CONTRAST_CURVE is supported, you can calculate your own version of a gamma 0.1 curve, though it may not be quite as accurate than a built-in version (due to the limits on how many points the tonemap curve can have). See TONEMAP_CURVE documentation for a sample 1/2.2 gamma curve to start with.

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47