Élodie Petit
Élodie Petit

Reputation: 5914

Background subtraction in OpenCV / EmguCV with fixed background

I need some samples / source code for a background subtraction algorithm for using with fixed backgrounds. The background I use is a fixed color background and unfortunately all the samples I've seen so far work for dynamic backgrounds.

Thank you.

Upvotes: 0

Views: 2856

Answers (2)

gankoji
gankoji

Reputation: 851

Keep in mind that you will suffer from a lot of noise with the subtraction technique. To avoid it, you could always use your best friend in fighting noise: blur, or GaussianBlur.

There's also a fascinating discussion of a statistical approach to this, called 'Code Booking,' in the O'Reilly book "Learning OpenCV."

Another technique for improving your results, provided your intended foreground objects are slow and/or your camera is fast, is to use many images and their differences, as opposed to just two. the programming for that should be easy enough, but as they say in most books: I leave it as an exercise for the reader ;).

Upvotes: 2

ArtemStorozhuk
ArtemStorozhuk

Reputation: 8725

What about simple frame subtraction? One frame is always the same - it's background, and another frame is frame from videostream. Convert both of them to grayscale and do absdiff operation. Here's my video result (look at center frame).

Upvotes: 1

Related Questions