문제

I have the following code.

cv::VideoCapture capture;
cv::Mat image;
cv::Mat foregroundMask
cv::BackgroundSubtractorMOG2 backgroundModel;

// update background model
for(int i = 0; i < 10; ++i)
{
    capture >> image;
    backgroundModel(image, foregroundMask);
}

//clear background model
// TODO   

// update background model    
for(int i = 0; i < 10; ++i)
{
    capture >> image;
    backgroundModel(image, foregroundMask);
}

How can I clear the background model and update it again from beginning? Like it has not been updated before. What should be the code to replace the TODO part in the code above?

도움이 되었습니까?

해결책

Call void initialize(Size frameSize, int frameType); method.

//clear background model
backgroundModel.initialize(image.size(), image.type());

According to source code thie methos will clear internal model.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top