Background Subtraction with changing light

Hi,

I am trying to build up people counter … but the camera is very low and near a spot light…when someone enters , takes all the light from the spot light and reflects the light everywhere…making the MOG2 going crazy !!

You can see what happens in this video: https://www.youtube.com/watch?v=KmK_38PsN7o

Any Idea on how to improve background subtraction ?

I thought to evaluate over all frames the total average light (AV_light) and then the light for the current frame (CU_light) and the difference Diff_light=CU_light - AV_light

then I could do:
New_Current_Mat = Current_Mat + cv::Scalar(Diff_light,Diff_light,Diff_light);

what do Yout Think?

Any other smarter Idea?

Any other better background subtraction other MOG2?

tks,

pippo

Hi,
Perhaps this method:
Take only a part of the camera image, for example the part bounded by the green rectangle in your youtube video

  • (1) compute the difference level between the current frame and a frame where nobody is present.
  • when the difference level is higher than a threshold, increase the counter.
  • wait for the difference level to come back smaller than the threshold.
  • goto (1)

The difference level should be a number which give you the similarity between 2 frames. I don’t know a convenient or efficient method to compute it with opencv, but I guess it’s not difficult. Perhaps compute the difference between the 2 frames, pixel by pixel, then sum all the pixels values from this difference?

I gave it a simple try:
RoughFrameDifference.zip (2.2 KB)
I don’t use opencv to compute the difference level, I just average the absolute difference between two ofPixels frames.
Seems to work.