Drashti_Patel
Drashti_Patel

Reputation: 31

How to extract foreground form a moving camera by using Opencv

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!!

Upvotes: 2

Views: 1617

Answers (2)

Al K
Al K

Reputation: 1

If your camera is moving would it not be possible to readjust the input images angle and zoom in a photo editor type program based on the cameras previous position. The idea here is to average out the motion of the camera such that the target will be "still enough" for the detection algorithm?

Upvotes: 0

Yunus Temurlenk
Yunus Temurlenk

Reputation: 4352

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

Upvotes: 2

Related Questions