Ask Your Question
1

background detection tutorial: error using MOG pointers

asked 2013-10-09 16:16:32 -0600

rickzor gravatar image

Hi everyone, I was trying to go through this background detection tutorial:

http://docs.opencv.org/trunk/doc/tutorials/video/background_subtraction/background_subtraction.html#background-subtraction

The MOG pointer is initialized as

Ptr<BackgroundSubtractor> pMOG; //MOG Background subtractor

and in main, it is used in the following manner:

pMOG = createBackgroundSubtractorMOG();

However, this yields the following error:

Error: Identifier "createBackgroundSubtractorMOG" is undefined

Also, when the background model is to be updated, the following command is used:

pMOG->apply(frame, fgMaskMOG);

Which in turn yields the following error:

Error: class "cv::BackgroundSubtractor" has no member "apply"

Any idea of what can be done about this?

Many thanks in advance!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-10-10 01:20:04 -0600

Vladislav Vinogradov gravatar image

Which version of OpenCV do you use? createBackgroundSubtractorMOG was added in master branch and will be available in the next major release. In 2.4 version BackgroundSubtractorMOG is used that way:

BackgroundSubtractorMOG mog;
mog(frame, fgMaskMOG);

And don't forget to include opencv2/video/video.hpp header.

edit flag offensive delete link more

Comments

@VladislavVinogradov Is it true some version of OpenCV doesn't have MOG? I'm using version 3.0.0 rc1. When I check background_segm.hpp, there is only for MOG2 & KNN method.

Aj-611 gravatar imageAj-611 ( 2016-02-15 00:53:57 -0600 )edit

Yes, it looks like MOG was removed from 3.0.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2016-03-03 01:05:17 -0600 )edit
0

answered 2016-08-31 15:33:16 -0600

mhaghighat gravatar image

If you want the MOG to work, you should

#include "opencv2/bgsegm.hpp"

and then

pMOG = bgsegm::createBackgroundSubtractorMOG();
edit flag offensive delete link more

Comments

Thanks, it worked! It might be important to mention that in addition to your answer opencv2/video.hpp should be included as well (as Vladislav Vinogradov mentioned in his solution)

Reka gravatar imageReka ( 2019-05-08 05:00:09 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-10-09 16:16:32 -0600

Seen: 3,168 times

Last updated: Oct 10 '13