OpenCV absdiff()错误:输入参数的大小不匹配

时间:2017-12-09 21:43:27

标签: opencv

我在absdiff(grayImg, bgImg, diffImg);上有错误 而且我不明白为什么这是错误的。

VideoCapture capture;
capture.open(0);

if (!capture.isOpened()) {
    printf("error\n");
    return -1;
}

Mat grayImg;
Mat diffImg;
Mat bgImg = imread("BgImg.jpg");
Mat frame;

std::vector<std::vector<cv::Point> > contours;

for (;;) {
    capture >> frame;
    cvtColor(frame, grayImg, CV_RGB2GRAY);
    absdiff(grayImg, bgImg, diffImg);
    threshold(diffImg, diffImg, 50, 255, CV_THRESH_BINARY);
    findContours(diffImg, contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
    drawContours(frame, contours, -1, CV_RGB(255, 0, 0), 1, 8);
    imshow("capture", frame);
    imshow("diffImg", diffImg);

    char chKey = waitKey(10);
    if (chKey == 27) break;

}
destroyAllWindows();
return 0;

0 个答案:

没有答案