First time here? Check out the FAQ!

Ask Your Question
4

Object detection using background Subtraction

asked Feb 24 '13

ranger gravatar image

updated Feb 24 '13

Okay I have ezperimented with lot of haar cascades, HOG and all but none of them was very efficient to meet my purpose. I am working on a video processing project which include tracking of humans (mainly). I have a static background in hand (always). So I thought detecting the foreground objects would be very easy. I used subtracting method like this :

cv::Mat temp;
cv::subtract(camFrame,backImage,temp);
cv::threshold(temp,temp,25,255,cv::THRESH_BINARY);

But this doesnt seem to work well in getting only the foreground objects.I thk the varying lighting effects is also given as foreground from this. Is there anything I am missing in this process??. Everybody said its very easy if theres a static background. I am very new to image processing in opencv. I will be glad if somebody can help me out and appreciate some code as well

Preview: (hide)

1 answer

Sort by » oldest newest most voted
9

answered Feb 25 '13

Siegfried gravatar image

Hi, OpenCV provides you several different background subtraction algorithms (OpenCV BackgroundSubtractor). In your case you can try BackgroundSubtractorMOG which implements the algorithm of the paper "An improved adaptive background mixture model for real-time tracking with shadow detection, Proc. 2nd European Workshop on Advanced Video-Based Surveillance Systems, 2001: http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf

Preview: (hide)

Comments

Sir I have a static background...I need something like this https://www.youtube.com/watch?v=KRKKektCcok sir... Cant really find it but I m trying...I m very new to image processing...

ranger gravatar imageranger (Feb 25 '13)edit
1

Hi, take a look at the cpp samples folder of OpenCV. There is a sample file bgfg_gmg.cpp (see here: http://code.opencv.org/projects/opencv/repository/revisions/master/entry/samples/cpp/bgfg_gmg.cpp). Run this example with a video file as param (eg. ./bgfg_gmg yourVideo.avi) to see how it works. If you run the sample without any parameter, the program try to use your webcam. To play around with different background subtraction algorithms, replace the algorithm (BackgroundSubtractorGMG) by your preferred one.

Another example with a brief documentation can be found here (http://mateuszstankiewicz.eu/?p=189)

Siegfried gravatar imageSiegfried (Feb 25 '13)edit

sorry, the above link (http://mateuszstankiewicz.eu/?p=189) died !

hosjiu gravatar imagehosjiu (Oct 6 '17)edit

Question Tools

1 follower

Stats

Asked: Feb 24 '13

Seen: 26,477 times

Last updated: Feb 25 '13