Ask Your Question

MOB's profile - activity

2019-06-10 07:06:05 -0500 received badge  Popular Question (source)
2016-05-19 09:06:30 -0500 received badge  Editor (source)
2016-05-19 09:03:29 -0500 asked a question Background Subtraction using running average in opencv

Hi, everybody ! i used Background Subtraction using running average, but i can't runnn ! thank you so much !!

#include "opencv2/opencv.hpp"

using namespace cv;

int main()
{
VideoCapture cap(0); // open the default camera
if (!cap.isOpened()) // check if we succeeded
    return -1;

// Variables
Mat frame;
Mat accumulator;
Mat scaled;

// Initialize the accumulator matrix
accumulator = Mat::zeros(frame.size(), CV_32FC3);

while (1) {
    // Capture frame
    cap >> frame;

    // Get 50% of the new frame and add it to 50% of the accumulator
    accumulateWeighted(frame, accumulator, 0.5); //error in hereeeeee!

    // Scale it to 8-bit unsigned
    convertScaleAbs(accumulator, scaled);

    imshow("Original", frame);

    imshow("Weighted Average", scaled);

    waitKey(1);
}

}