Question

Is there any OpenCV 2.4.2 function or class that implements an Image Background Subtraction algorithm?

The images I will be processing will be portraits, such as images from a webcam. I want to keep only the upper part of the body (from the chest upwards) and remove everything else in the background.

If possible I'd like to avoid implementing these algorithms myself. However, should none currently exist in OpenCV then please suggest me some.

I tried to look for an answer but so far everything I've found only deals with Background Subtraction in videos or in sequences of pictures and that's not what I want. I want to process single, static and independent images only.

Was it helpful?

Solution

You can try the running average method for this using cvRunningAvg function in OpenCV (or any other library).

In this, you take average of a lot of frames as background. If camera is static, it provides a good result, especially if you have some frames with only background.

Look at a sample result :

original frame backgroundthe

It is also better to apply some morphological operations like erosion,dilation etc to remove small noises while frame grabbing.

You can read the code and explanation here : BackGround Extraction using Running Average

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top