Ask Your Question
0

BackgroundSubsr

asked 2014-03-03 13:23:19 -0600

carlospalma03 gravatar image

updated 2014-03-03 13:23:46 -0600

Hello, I can´t seem to be able to use the BackgroundSubstractor class. I tried to follow the tutorial like this:

 Ptr<BackgroundSubstractor> bg;
...
 bg= createBackgroundSubstractor();

the compiler tells me that create BackgroundSubstractor() is not defined.

I have also tried this:

BackgroundSubstractor bg;
bg=new BackgroundSubstractor();

but I get the error

      undefined reference to cv::BackgroundSubstractorMOG::BackgroundSubstractorMOG()

Any help will be much appreciated

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2014-03-03 14:29:21 -0600

Will Stewart gravatar image

updated 2014-03-14 13:09:45 -0600

Declare your instance as;

cv::BackgroundSubtractorMOG bg;

or

cv::BackgroundSubtractorMOG2 bg;

In your loop;

bg.operator ()(frame,fore);

BackgroundSubtractor itself is only used to define the common interface for the whole family of background/foreground segmentation algorithms.

See this example; http://mateuszstankiewicz.eu/?p=189

edit flag offensive delete link more

Comments

2

I was using this: bg->operator()(frame,fore); after defining bg using smartpointers, like in the tutorial, but I got a black box. With your syntax it works! thank you very much

carlospalma03 gravatar imagecarlospalma03 ( 2014-03-03 14:52:58 -0600 )edit

I updated the answer to point out that you can use BackgroundSubtractorMOG as well, which implements a different algorithm. Try both to see which one works best for you, noting that there are a number of parameters you can adjust.

Will Stewart gravatar imageWill Stewart ( 2014-03-14 13:07:43 -0600 )edit

Question Tools

Stats

Asked: 2014-03-03 13:23:19 -0600

Seen: 767 times

Last updated: Mar 14 '14