# Revision history [back]

### Cannot set user parameters in BackgroundSubtractorMOG2

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 is a private member
bgr.nmixtures = 3;

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

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


backgroundRatio and fVarMin are parameters that control the algorithm. These parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned here.

How can I set the parameters of BackgroundSubtractorMOG2?

### Cannot set user parameters in BackgroundSubtractorMOG2

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 is a private protected member
bgr.nmixtures = 3;

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

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


backgroundRatio and fVarMin are parameters that control the algorithm. These parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned here.

How can I set the parameters of BackgroundSubtractorMOG2?

### Cannot set user parameters in BackgroundSubtractorMOG2

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 is 'nmixtures', 'backgroundRatio' and 'fVarMin' are a protected member
members
bgr.nmixtures = 3;
bgr.backgroundRatio = 0.9;
bgr.fVarMin = 5;

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

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


backgroundRatio and fVarMin are parameters that control the algorithm. These parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned here.

How can I set the parameters of BackgroundSubtractorMOG2?

### Cannot set user parameters in BackgroundSubtractorMOG2

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, both of the following lines will give a run-time error
// Access violation reading location 0x0000000000000008.
bgr.set("backgroundRatio", 0.9);
bgr.set("fVarMin", 5);


backgroundRatio and fVarMin are parameters that control the algorithm. These parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned here.

How can I set the parameters of BackgroundSubtractorMOG2?

### Cannot set user parameters in BackgroundSubtractorMOG2

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
protected
bgr.nmixtures = 3;
bgr.backgroundRatio = 0.9;
bgr.fVarMin = 5;

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

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


backgroundRatio and fVarMin are parameters that control the algorithm. These parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned here.

How can I set the parameters of BackgroundSubtractorMOG2?

### Cannot set user parameters in BackgroundSubtractorMOG2

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
protected members.
bgr.nmixtures = 3;
bgr.backgroundRatio = 0.9;
bgr.fVarMin = 5;

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

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


backgroundRatio and fVarMin are parameters that control the algorithm. These parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned here.

How can I set the parameters of BackgroundSubtractorMOG2?

### Cannot set user parameters in BackgroundSubtractorMOG2

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, both of 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. These parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned here.

How can I set the parameters of BackgroundSubtractorMOG2?

### Cannot set user parameters in BackgroundSubtractorMOG2

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. These A user should be able to change these parameters can be changed by user after constructing the instance of BackgroundSubtractorMOG2 class as mentioned stated in herethe documentation.

How can I set the parameters of BackgroundSubtractorMOG2?