Trigger on background color change

Hi all

I use the cam to detect a moving object passing in front of a black background.
Light seems to affect my trigger using l_ mean from image statistics only
Something like :

Img.capture
St=ing.statistics
while st.l_ mean > 19:
Do Analyse object…
Img.capture
St=ing.statistics


What is the best way to eliminate small light differences so the trigger becomes more’ stable’
So more like get the colour from image statistics regardless lighter or darker?

So if capture 1 one is at say x light and capture 2 is at x-1 Light
How you calculate capture 2 back to one?

Kind regards

Hi, you have to expect there will be some noise in the system and that you can’t eliminate it. However, you can always compare the difference in brightness between the current image and the previous image and then threshold based on that. If something changes the difference between the lightness in the old image and the new image will be bigger than the threshold.

If you want good filtering… the easiest thing to do is a moving average. In python this is easy. Just keep a list of the last N or so values and throw away the last value i the list if it gets larger than N. then to compute the average just do sum() of the list divided by N.

Hi

Thanks for the advice :smiley:
I will do just that…
The system is to detect products without labels on a filling machine but some labels are transparent with just some white or black text on it…
I count lines and a total difference over the stats to compare current and previous…
That’s seems to do the job, but timing of the capture is critical here…

Thx again…