title: How to get Color Temperature from Color Correction Gain
body: <p>I am trying to find out the Color Temperature of a Photo captured by the Camera.</p>
  
  <pre><code>final CameraCaptureSession.CaptureCallback previewSSession = new CameraCaptureSession.CaptureCallback() {
      @Override
      public void onCaptureStarted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, long timestamp, long frameNumber) {
          super.onCaptureStarted(session, request, timestamp, frameNumber);
      }
  
      @Override
      public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, TotalCaptureResult result) {
          super.onCaptureCompleted(session, request, result);
          RggbChannelVector rggbChannelVector = result.get(CaptureResult.COLOR_CORRECTION_GAINS);
          getColorTemperature(rggbChannelVector);
  
          startCamera();
      }
  };
  
  private void getColorTemperature(RggbChannelVector rggbChannelVector) {
      //rggbChannelVector.getRed() = 2.192929
      //rggbChannelVector.getGreenEven() = 1.0
      //rggbChannelVector.getGreenOdd() = 1.0
      //rggbChannelVector.getBlue() = 1.832323
  }
  </code></pre>
  
  <p>iOS seems to have a readily available method to do that <a href="https://developer.apple.com/documentation/avfoundation/avcapturedevice/1624640-temperatureandtintvalues" rel="noreferrer">temperatureAndTintValues</a></p>
  
  <p>While searching for something similar(in Java or any other language which I can adopt), almost all such methods expect a RGB value with <code>[0, 255]</code> range.</p>
  
  <p>There are few methods to convert XYZ to CCT(Correlated Color Temperature) but even to get the XYZ value correct I need RGB values with in <code>[0, 255]</code></p>
  
  <p>As you can see the values from <code>COLOR_CORRECTION_GAINS</code> are <code>&gt;1</code> i.e greater than 255 which is not unusual because its a gain and iOS returns similar values(greater than 1).</p>