BackgroundSubtractorMOG2 with ofVideoGrabber

Hello everyone, I want to use opencv background subtractor from my web camera using videograbber, but I got white screen.

here is my function

void ofApp::update()
{
    videoGrabber.update();
    if(videoGrabber.isFrameNew()){
        Mat cImage = toCv(videoGrabber.getPixels());
        resize(cImage, resized, cv::Size(cImage.size().width, cImage.size().height));
        
        lightenMat = resized + cv::Scalar(_lightenAmount,_lightenAmount,_lightenAmount);
        
        // Activate the background substraction
        pMOG2->operator()(lightenMat, processedMog);
        
        threshold(processedMog, config.getSettings().threshold);
        blur(processedMog, config.getSettings().blur);
        dilate(processedMog);
        
        tracking.lock();
        tracking.getCameraImage(processedMog);
        tracking.unlock();
    }
}
//--------------------------------------------------------------
void ofApp::draw()
{
    ofBackground(25);
    tracking.draw(0, 0);
    tracking.drawHistory(0, 0);
}

Thank you before

Hi @raditiya,

Lower the _lightenAmount value. The Scalar is increasing matrices values.

Otherwise.

Mat cImage;

ofxCv::copy(videoGrabber,cImage);

Best