<< return to Pixycam.com

How pixy's color tracking removes the effects of lighting changes

I’m trying to figure out how the pixy deal with the effects of lighting changing in a scene. And can I interpret the region grow as segmentation using the thresholds? Thanks!

Hello,
“interpret the region grow as segmentation using the thresholds”. I’m not sure what you mean by "region grow and which thresholds you are referring to.

Edward

Thanks for your reply, Firstly I mainly want to know how pixy’s color tracking eliminates the effects of lighting changes. And secondly, pixy using region grow for color target extraction in tracking, so can I understand the region grow as using the parameters ‘u’ and ‘v’ defined in the program as color thresholds for target extraction?

Hello,
Pixy focuses on the hue instead of the brightness of the object. It does this by forming a pure hue in 2 dimensions –
U = (R-G)/Y
V = (B-G)/Y

where R=red, G=green, B=Blue, Y=R+G+B

It then determines what bounds of U and V are associated with a given object.

Since it divides by Y, the brightness is mostly ignored and changes in lighting have less of an effect.

Pixy does not use region growing when tracking/detecting objects.

Hope this helps!

Edward

Thanks!
In the source code,
U = (((R-G)<<15)/Y)
V = (((B-G)<<15)/Y)
Does this mean to increase the (R-G) and (B-G) by 2^15 times and then divides by Y? And are the variable types of U and V int32 or others?

Hello,
I believe you are correct about everything.

Edward

Thanks for your reply!

Hi,
I was also wondering about the effect of lighting. I have noticed that in ccc-mode adjusting the camera brightness does effect the detection of objects.
I also noticed that the FPS is reduced with less light. I connected Pixy2 to an Arduino and want to have optimum detection performance. Therefor whenever the FPS is less than 50 I increase camera brightness. However, I have no indication when the image is overexposed. What is the best brightness level? And is there a way to control it via camera brightness?
Thnx, Sydney

Hello,
Yes, under and overexposure of pixels negatively affects the detection of objects.

In general, the autoexposure algorithm will increase the shutter time to increase the brightness. This will create the best image. It may reduce the framerate, depending on your “Min frames per second” setting:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixymon_index#camera-tab

It will not reduce the frames per second below this setting, however.

The best brightness level sometimes depends on the objects you are detecting. If they tend to be darker objects, setting the brightness higher will help and vice versa.

Hopefully that helps answer your questions.

Edward

Hi Edward,
I do not understand the above statement.
Suppose the light increases. I suppose that the R, G and B values also increase. The U & V values therefor decrease in triple, because the top value will not increase (the difference will be approx be the same) and the division (Y=R+G+B) will increase 3 times…
Where does my logic fault? And more importantly how can I compensate for this?

Regards, Sydney

Hi Sydney,
Let me try to explain this way –

Color of an object = some combination of R, G, B -- let's call it Ro, Go, Bo
Color of object in brighter lighting = a*Ro, a*Go, a*Bo (where a is some number > 1)

You can see how the “a” term falls out of the U, V expressions. This is how brightness is discounted inside Pixy.

Things can go wrong where either R, G, or B are saturated – when any channel hits 255. When this happens, the hue will change as the object gets brighter. The same thing happens when any channel hits 0 in low-lighting situations.

Hope this helps :slight_smile:
Edward

Hi Edward,

I get it. That’s the fault in my logic.

I am trying to get an optimum brightness in all sorts of lighting.
So, basically, the saturation of a channel is the indication I am looking for. If a channel is saturated (ie 255) I should reduce the camera brightness. When the FPS is less than 60 I should increase camera brightness. (I will not wait until one channel is 0.) This way I get the optimum. I will set up a test.

Thanks, this does help!
Kind regards, Sydney

1 Like