Improve openCV Background subtraction

asked 2017-12-29 21:34:07 -0600

malharjajoo gravatar image

updated 2017-12-31 14:40:37 -0600

Hi,

Update: I tried using simple absdiff(current_frame, background) + thresholding , and it gives me a better result than all 3 below. I am now curious why openCV has provided these (MOG, MOG2,GMG) Algorithms ? Are they supposed to work better ( than frame difference ) for varying lighting conditions, or with changing static backgound ( background image changing after a few frames have elapsed ) ?

I have been looking at openCV Background Subtraction methods ( MOG, MOG2, GMG ,etc). but it gives very poor results ( see below ).

Final Use Case: Detect (using fixed stereo cameras) a moving Parrot A.R. Drone in a indoor/outdoor environment.

How you can help me:

  1. If an object(drone) is moving slow/fast , how would background subtraction algorithm need to be adjusted for that ? My (very little) experience tells me there are a lot of "transparent/black" areas in the output in such cases and I am not aware on how this can be avoided.

  2. After seeing the images below, I would like to know your opinion/experience on how these can be improved. I can think of a few methods to improve these results ( eg: I have tried MOG + dilation to improve results , usage of HSV/LAB color spaces for potential robustness to lighting conditions,etc)

Thanks!!

Original image frame from a video( in which I move drone manually): C:\fakepath\original.png

Comparison of 3 methods below:

  1. MOG C:\fakepath\mog.png
  2. MOG2 C:\fakepath\mog2.png
  3. GMG C:\fakepath\gmg.png

edit retag flag offensive close merge delete

Comments

How many frames long is the video before this?

Tetragramm gravatar imageTetragramm ( 2017-12-29 21:39:53 -0600 )edit

I can see you keep editing the question, but I don't see any changes. Please use the comments.

Tetragramm gravatar imageTetragramm ( 2017-12-30 09:57:28 -0600 )edit

Sorry for late reply. It's frame number 137.

malharjajoo gravatar imagemalharjajoo ( 2017-12-31 14:35:51 -0600 )edit

So, you may notice, while looking at the settings, that the methods typically use 200-500 frames of video. 137 should work for pretty un-noisy scenes. Unfortunately, that's not what you have. Your camera compresses the video pretty severely with jpg compression, leading to all those square blocks.

Try giving it a good 500 frames of background before moving the drone into the image and see what that does. Also explore the camera settings to see if you can reduce the effects of compression.

Tetragramm gravatar imageTetragramm ( 2018-01-01 17:09:04 -0600 )edit

Thanks for the advice, I will try it out soon. But I don't follow why jpeg compression would lead to those speckles ( white dots ) in the background (?)

malharjajoo gravatar imagemalharjajoo ( 2018-01-01 17:48:16 -0600 )edit