I am trying to find out the Color Temperature of a Photo captured by the Camera.
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
}
iOS seems to have a readily available method to do that temperatureAndTintValues
While searching for something similar(in Java or any other language which I can adopt), almost all such methods expect a RGB value with [0, 255] range.
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 [0, 255]
As you can see the values from COLOR_CORRECTION_GAINS are >1 i.e greater than 255 which is not unusual because its a gain and iOS returns similar values(greater than 1).