Ask Your Question
4

Object detection using background Subtraction

asked 2013-02-23 21:54:18 -0600

ranger gravatar image

updated 2013-02-23 21:55:12 -0600

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
9

answered 2013-02-25 01:50:49 -0600

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

edit flag offensive delete link more

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 ( 2013-02-25 06:36:27 -0600 )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 ( 2013-02-25 08:24:45 -0600 )edit

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

hosjiu gravatar imagehosjiu ( 2017-10-05 23:18:54 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-02-23 21:54:18 -0600

Seen: 26,241 times

Last updated: Feb 25 '13