Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to do Background substraction

Can someone please help me with a few lines on background substraction? I want to remove a.k.a "substract" the background and highlight the foreground images.

I tried with BackgroundSubstractorMOG2 method but apparently most parameters (e.g. nmixtures & bShadowDetection) are protected hence cannot play around. Also, the following code throws a memory exception:

namedWindow("bg-window",CV_WINDOW_AUTOSIZE);

for(;;)
{
....

bg(frame,foreground);
bg.getBackgroundImage(background);
imshow("bg-window",background);

....
}