Ask Your Question
0

Cannot set user parameters in BackgroundSubtractorMOG2

asked 2012-10-12 13:07:56 -0500

alex gravatar image

updated 2012-10-14 10:24:18 -0500

OpenCV library version 2.42. I'd like to set a parameter in BackgroundSubtractorMOG2 object, e.g.

BackgroundSubtractorMOG2 bgr;

// the following doesn't work because 'nmixtures', 'backgroundRatio' 
// and 'fVarMin' are a protected members.
bgr.nmixtures = 3;   
bgr.backgroundRatio = 0.9;
bgr.fVarMin = 5;

// the following works 
bgr.set('nmixtures', 3); 

// However, the following lines will give a run-time error 
// `Access violation reading location 0x0000000000000008.`
bgr.set("backgroundRatio", 0.9);  
bgr.set("backgroundRatio", (float) 0.9);
bgr.set("fVarMin", 5);

backgroundRatio and fVarMin are parameters that control the algorithm. A user should be able to change these parameters after constructing the instance of BackgroundSubtractorMOG2 class as stated in the documentation.

How can I set the parameters of BackgroundSubtractorMOG2?

edit retag flag offensive close merge delete

Comments

It's not private - it's protected. It's a different thing (see encapsulation).

Astor gravatar imageAstor ( 2012-10-12 15:16:01 -0500 )edit

ok, so how can I set its value?

alex gravatar imagealex ( 2012-10-12 16:46:36 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-10-23 08:02:03 -0500

alex gravatar image

updated 2012-10-23 08:02:31 -0500

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-10-12 13:07:56 -0500

Seen: 2,160 times

Last updated: Oct 23 '12