Ask Your Question
0

BackgroundSubtractorMOG2 set parameters

asked 2015-11-09 06:06:57 -0600

giuseppedes gravatar image

Hi, i'm trying to use the class BackgroundSubtracorMOG2 with Opencv 3.0.

After:

Ptr<BackgroundSubtractor> pMOG2;

pMOG2 = createBackgroundSubtractorMOG2();

I want to set some parameters like:

    pMOG2.setShadowThreshold(0.5);

But it tells me:

No member named 'setShadowThreshold' in 'cv::Ptr<cv::backgroundsubtractor>'

Same with the operator "->" instead of "."

Do you know how to set parameters of this class?

edit retag flag offensive close merge delete

Comments

3

correct usage is like below :

Ptr<BackgroundSubtractorMOG2> pMOG2 = createBackgroundSubtractorMOG2();
pMOG2->setShadowThreshold(0.5);
sturkmen gravatar imagesturkmen ( 2015-11-09 06:29:43 -0600 )edit
1

Since no-one explains why it is failing. The overall BackgroundSubtractor object does not have that specific function, therefore you need a pointer to an object of the correct type, which is BackgroundSubtractorMOG2 in this case.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-09 08:34:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-11-09 06:25:03 -0600

LBerger gravatar image

updated 2015-11-09 06:48:54 -0600

Something like this :

if (pMOG2.dynamicCast<cv::BackgroundSubtractorMOG2>()!=NULL)
    pMOG2.dynamicCast<cv::BackgroundSubtractorMOG2>()->setShadowThreshold(0.5);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-09 06:06:57 -0600

Seen: 1,844 times

Last updated: Nov 09 '15