Trigger on background color change

OpenMV related project discussion.
fsikkerm
Posts: 3
Joined: Wed Nov 21, 2018 5:21 pm

Trigger on background color change

Postby fsikkerm » Sat Dec 08, 2018 11:13 am

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
User avatar
kwagyeman
Posts: 2467
Joined: Sun May 24, 2015 2:10 pm

Re: Trigger on background color change

Postby kwagyeman » Sat Dec 08, 2018 11:05 pm

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.
Nyamekye,
fsikkerm
Posts: 3
Joined: Wed Nov 21, 2018 5:21 pm

Re: Trigger on background color change

Postby fsikkerm » Sun Dec 09, 2018 10:15 am

Hi

Thanks for the advice :D
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..

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest