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);
}
}