2

I am performing motion detection using OpenCV. Challenge is that camera is moving so frame differencing is not a technique to be used directly. So I am trying to separate foreground and background and after that performing frame differencing on foreground images.

Ques is that how to separate foreground and background from a video taken from moving camera??

Any help from your side would be thankful to you!!

Yunus Temurlenk
  • 4,085
  • 4
  • 18
  • 39

1 Answers1

1

Subtracting background is an important technique to generate a foreground mask and its used widely in applications.

Many of the techniques which are used to get background subtraction assumes that camera is constant. Up to now I didn't see any paper or example which works with a moving camera.

You may have a look at the opencv example in here, which is very useful for background subtraction. Especially MOG2 and KNN algorithms are really good at to find shadows which is a problem in background subtraction. I suggest you to take the history parameters of these algorithms so low(1 to 10), by doing this you may get some good results even I don't think.

The best but the difficult way I suggest you is that using an AI. If your desired objects are specific (like people, car etc. ), you can use an AI to detect those objects and subtract the rest of the frame. The most proper AI algorithm for this problem is Mask R-CNN which will detect the mask of the objects also. Here are the some examples of this:

  1. Reference 1
  2. Reference 2
  3. Reference 3
  4. Reference 4
Yunus Temurlenk
  • 4,085
  • 4
  • 18
  • 39
  • I want to detect the motion not a particular object So I cant go for this Mask R-CNN approach. Basically what I am doing is surveillance but camera is not static so background is also detecting as foreground. Which produces the false alarm. So I am trying approach of separating foreground and background . Then subtracting the foreground of two consecutive frame so that it detect the motion and rings the alarm. – Drashti_Patel Mar 31 '21 at 08:55