Ask Your Question
0

Background Subraction Tutorial

asked 2014-04-30 01:42:36 -0600

Fajre gravatar image

updated 2014-04-30 02:03:00 -0600

FLY gravatar image

Hi i'm implementing the opencv background subtraction MOG and MOG2 technique.The problem i'm facing is this that the moving objects are detected along with some black and white portion of the background.In general or in tutorial the background is black and only moving objects should be detected. What have i missed?? I mean should i set some threshold as well??

Mat frame; //current frame 
Mat fgMaskMOG; //fg mask generated by MOG method
Ptr<BackgroundSubtractor> pMOG; //MOG Background subtractor 
namedWindow("Frame"); 
namedWindow("FG Mask MOG"); 
pMOG = createBackgroundSubtractorMOG(); 
VideoCapture capture(videoFilename); 
pMOG->apply(frame, fgMaskMOG); 
imshow("Frame", frame); 
imshow("FG Mask MOG", fgMaskMOG);
edit retag flag offensive close merge delete

Comments

What you tried ? can you post your code , so we can find what is missing

FLY gravatar imageFLY ( 2014-04-30 01:48:34 -0600 )edit

Mat frame; //current frame Mat fgMaskMOG; //fg mask generated by MOG method Ptr<BackgroundSubtractor> pMOG; //MOG Background subtractor namedWindow("Frame"); namedWindow("FG Mask MOG"); pMOG = createBackgroundSubtractorMOG(); VideoCapture capture(videoFilename); pMOG->apply(frame, fgMaskMOG); imshow("Frame", frame); imshow("FG Mask MOG", fgMaskMOG);

Fajre gravatar imageFajre ( 2014-04-30 01:54:20 -0600 )edit
FLY gravatar imageFLY ( 2014-04-30 07:49:21 -0600 )edit

Thankyou i just changed video and tried the same code on that and it worked as intended. So my current video was wrong may be because of moving camera and this code needs a still camera to focus frames properly. Anyhow thanks once again.

Fajre gravatar imageFajre ( 2014-04-30 14:31:11 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-05-01 11:39:19 -0600

FLY gravatar image

For backgroundsubtraction you need to check this and then for further to detect thing whether its people or vehicle whatever , you need to apply object detection algorithms which suits your work , there are alot of object detection algorithm available , which you can search easily through google , you also need to check machine learning algorithms for that like SVM and latent SVM approach , do which suit your condition.SVM and Latent SVM

edit flag offensive delete link more

Comments

I just visited these links i have done background subtraction.. And in that everything else than moving objects went in the background. The foreground only contains the moving objects which are white in color and background is black. Now is it possible that i apply some condition that draw a rect on pixels marked as 255??

Fajre gravatar imageFajre ( 2014-05-01 11:46:27 -0600 )edit

yes it is poosible you can also throw a new question when you face dificulty in it after doing some work on your own

FLY gravatar imageFLY ( 2014-05-01 11:56:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-04-30 01:42:36 -0600

Seen: 525 times

Last updated: May 01 '14