Set wbRegion of camera

I would like to set a wbRegion of my camera to adjust global white balance focused on a sepecific area.
This area is located at the center of my picture. The picture dimensions are 3280 * 2464.
The white balance is automatic and the exposure is manual and fixed.

I took the documentation :

wbRegion            : Property to set region of interest for white balance.
			 Use GArray, with values of ROI coordinates (top,left,bottom,right)
			 and weight in that order, to set the property.
                        flags: readable, writable
                        Boxed pointer of type "GArray"

I understand the documentation in 2 ways :

  • I have an array of gint to provide ROI coordinates followed by a gfloat to provide weight.
GArray * array = g_array_new (FALSE, FALSE, sizeof(gint));
	gint top = 1100;
	gint left = 1300;
	gint bottom = 1400;
	gint right = 1900;
	gfloat weight = 1.2;

	g_array_append_val(array, top);
	g_array_append_val(array, left);
	g_array_append_val(array, bottom);
	g_array_append_val(array, right);
	g_object_set (m_source, "wbRegion", array, weight, NULL);
	g_array_free (array, FALSE);
  • I make a global GArray of float and put ROI coordinate and weight inside
GArray * array = g_array_new (FALSE, FALSE, sizeof(gfloat));
	gfloat top = 1100;
	gfloat left = 1300;
	gfloat bottom = 1400;
	gfloat right = 1900;
	gfloat weight = 0.5;

	g_array_append_val(array, top);
	g_array_append_val(array, left);
	g_array_append_val(array, bottom);
	g_array_append_val(array, right);
	g_array_append_val(array, weight);
	g_object_set (m_source, "wbRegion", array, NULL);
	g_array_free (array, FALSE);

I’ve try the both solution and no one give me valid results. Sometimes with a 1.5 weight the image is black and sometimes fully saturated. I’ve tried other coefficients with same results

I don’t know what is the good way and I don’t know what weight use for my region to say: “I would like this area not saturated”

Any idea ?

May wbRegion not for this purpose?

I need to set the auto white balance in a specific region of the picture, so yes I think it is made for this purpose.

Moreover, When I put a lamp to make a quick luminosity change outside of the defined region, the global white balance doesn’t change. And when I put the lamp inside the wbRegion the global luminosity change. I think my problem is only located with the wieght.

I can set any value of the weight (I’ve tried 0.5 to 4.5) and my area is always saturated and fully white.