[libcamera-devel] Rpi: Lux measurement and 18% grey

Jean-Michel Hautbois jeanmichel.hautbois at ideasonboard.com
Fri Sep 10 10:44:24 CEST 2021


Hi David, Naushir

While documenting ipu3 AGC (which is, as you know, greatly inspired by
your algorithms) I tried to find out more about the y_target value used
(which is also named Y_target) in your AGC. And I am not sure to really
know where the 0.16 value comes from:
        "y_target":
        [
            0, 0.16, 1000, 0.165, 10000, 0.17
        ],

Is it something like 16% reflectence of grey (not 18 ?) ?
Is it related to the K value in the Ev estimation ?
As it is a fixed value for all the sensors (generated by ctt.py) I
suppose it is a constant somehow, but where is it coming from ?

Another question I had, reading the lux class, is the estimation of Y in
your process() call:

	uint32_t *bin = stats->hist[0].g_hist;
	const int num_bins = sizeof(stats->hist[0].g_hist) /
			     sizeof(stats->hist[0].g_hist[0]);
	for (int i = 0; i < num_bins; i++)
		sum += bin[i] * (uint64_t)i, num += bin[i];
	// add .5 to reflect the mid-points of bins
	double current_Y = sum / (double)num + .5;

You are using only hist[0] which is AFAIK only R channel.
Using G channel only would probably be a better approximation, but why
not using the same calculation as the one in ctt, using the formula

	y = 0.299*r + 0.587*g + 0.114*b

I probably missed an information here ;-).

Thanks for your help on this one :-).
JM


More information about the libcamera-devel mailing list