Ask Your Question

Revision history [back]

You should used cv::bgsegm::createBackgroundSubtractorMOG(); in opencv 3.0

You should used cv::bgsegm::createBackgroundSubtractorMOG(); in opencv 3.0 and used same example include samples\cpp\tutorial_code\video\bg_sub.cpp

You should used cv::bgsegm::createBackgroundSubtractorMOG(); in opencv 3.0 and used same example include samples\cpp\tutorial_code\video\bg_sub.cpp

You should used cv::bgsegm::createBackgroundSubtractorMOG(); in opencv 3.0 You have a tutorial for MOG you can use this parameters for MOG

cv::Ptr<cv::BackgroundSubtractor> b;
b = cv::bgsegm::createBackgroundSubtractorMOG(); 
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setHistory(history);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setBackgroundRatio(BackgroundRatio);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setNMixtures(mixtures);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setNoiseSigma(NoiseSigma);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->apply(img, imDst,learningRate);

and this for MOG2

cv::Ptr<cv::BackgroundSubtractor> b;
    b = cv::createBackgroundSubtractorMOG2(); 
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setHistory(history);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setNMixtures(mixtures);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setBackgroundRatio(BackgroundRatio);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarThreshold(VarThreshold);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarThresholdGen(VarThresholdGen);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarInit(VarInit);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarMin(VarMin);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarMax(VarMax);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setComplexityReductionThreshold(ComplexityReductionThreshold);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setDetectShadows(DetectShadows);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setShadowValue(ShadowValue);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarThreshold(ShadowThreshold);
b.dynamicCast<cv::BackgroundSubtractorMOG2>()->apply(img, *imDst, learningRate);

You should used cv::bgsegm::createBackgroundSubtractorMOG(); in opencv 3.0 You have a tutorial for MOG you can use this parameters for MOG

cv::Ptr<cv::BackgroundSubtractor> b;
b = cv::bgsegm::createBackgroundSubtractorMOG(); 
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setHistory(history);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setBackgroundRatio(BackgroundRatio);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setNMixtures(mixtures);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->setNoiseSigma(NoiseSigma);
b.dynamicCast<cv::bgsegm::BackgroundSubtractorMOG>()->apply(img, imDst,learningRate);

and this for MOG2

cv::Ptr<cv::BackgroundSubtractor> b;
    b = cv::createBackgroundSubtractorMOG2(); 
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setHistory(history);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setNMixtures(mixtures);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setBackgroundRatio(BackgroundRatio);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarThreshold(VarThreshold);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarThresholdGen(VarThresholdGen);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarInit(VarInit);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarMin(VarMin);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarMax(VarMax);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setComplexityReductionThreshold(ComplexityReductionThreshold);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setDetectShadows(DetectShadows);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setShadowValue(ShadowValue);
    b.dynamicCast<cv::BackgroundSubtractorMOG2>()->setVarThreshold(ShadowThreshold);
b.dynamicCast<cv::BackgroundSubtractorMOG2>()->apply(img, *imDst, imDst, learningRate);

PS I haven't test syntax