Background Subraction Tutorial
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);
What you tried ? can you post your code , so we can find what is missing
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);
check this out my be you got help here http://answers.opencv.org/question/15724/error-in-backgroundsubtraction-mog2/
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.