I am trying to use a phone as a colour measuring instrument.
This is not a colour science question. I know the any conversion will be approximate, and I will get different results for different illuminant spectra. However, I hope if I can get close enough, the user can use their eyes to fine-tunead the result.
I am getting proxy images previews from the camera. I am averaging the YUV values from the middle 1/5th square of the view. I tried turning off white balance, but the image came out very green, so I set it to daylight, as most monitors are D65. I could convert from Rec.601 YUV to RGB, and linearise the RGB assuming the sRGB tone curve. I read the exposure time and the sensitivity. I scaled the result by 250.0 / (sensitivity * exposure time in seconds) and I am getting XYZ values that look sensible.
I fixed the white balance to daylight because I did not want the white balance in the region I was measuring to be affected by what lay outside this region. Might I be better off getting the white balance settings and correcting?
The 250.0 constant was set by hand for my phone. Is there a value I ought to be using? Or will it vary with focus, lens zoom, and other parameters? The light level does seem to decrease when I put the camera very close to a display
I know every camera may be different, but I would be grateful for any general hints that might save me some time.
Here's a bit of background, which may show what I am aiming for...
I have done the other half of the job on the display. I adjust the screen gamma and offset (it does not always for the sRGB defaults). If I put up a digital Macbeth image on a display I trust, and get a visual match for the red, green, blue, and a grey on the display, I can calibrate the display white and primaries (again, not quite sRGB). Then, if I match a patch of colour on my phone display, I can read off the XYZ colours. It is not as good as my spectrometer, but it works, and maybe I can make it better. I imagine I may have to put the same sort of effort into calibrating the camera, or have it measure its own display in a mirror, or something. But a good set of starting values would help.