OpenCV3 Assertion failed on accumulateWeighted

asked 2016-06-30 23:16:39 -0600

Lafi gravatar image

I try to make average background but something wrong because it way to crash app

`

include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;

int main(int argc, char *argv[])

{
VideoCapture video(0);

cv::Mat Frame,Gray, Avg;

Avg = Mat::zeros(Frame.size(),CV_8UC1);

while(true)
{
    video >> Frame;
    cv::cvtColor(Frame,Gray,CV_BGR2GRAY);
    int c = Avg.channels();
    cv::accumulateWeighted(Gray,Avg,0.5);
    cv::convertScaleAbs(Avg,Avg);
    cv::namedWindow("Video");
    cv::namedWindow("Avg");
    cv::imshow("Avg",Avg);
    cv::imshow("Video",Gray);
    std::cout << c << std::endl;
    std::cout << GetMatType(Gray) << std::endl;
    cv::waitKey(30);
}

cv::waitKey(0);

return 0;

} `

This is the crash logs :::

OpenCV Error: Assertion failed (_src.sameSize(_dst) && dcn == scn) in accumulateWeighted, file /home/lafi/Documents/opencv-master/modules/imgproc/src/accum.cpp, line 1201
terminate called after throwing an instance of 'cv::Exception'


what():  /home/lafi/Documents/opencv-master/modules/imgproc/src/accum.cpp:1201: error: (-215) _src.sameSize(_dst) && dcn == scn in function accumulateWeighted
edit retag flag offensive close merge delete

Comments

Avg = Mat::zeros(Frame.size(),CV_8UC1); <-- Frame.size = (0,0) here

berak gravatar imageberak ( 2016-07-01 01:14:43 -0600 )edit

how i can correct it since i have to initialize the accumulator ??

Lafi gravatar imageLafi ( 2016-07-01 18:20:18 -0600 )edit