【发布时间】:2015-12-02 15:17:32
【问题描述】:
我正在尝试用下面的代码做帧差异。当我运行它时,它只显示第一帧并崩溃。你能帮忙看看为什么会这样吗
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main()
{
cv::Mat frameCurrent, framePrev;
cv::Mat frameAbsDiff=;
//prepare Mats
VideoCapture cap("e.mp4");
cap >> frameCurrent;
framePrev = cv::Mat::zeros(frameCurrent.size(), frameCurrent.type());
cvtColor(frameCurrent, frameCurrent, CV_BGR2GRAY);
frameCurrent.copyTo(framePrev);
while (1)
{
if (frameCurrent.empty()) {
std::cout << "Frame1Message->End of sequence" << std::endl;
break;
}
cv::absdiff(frameCurrent, framePrev, frameAbsDiff);
imshow("frameCurrent", frameCurrent);
imshow("frameAbsDiff", frameAbsDiff);
if (waitKey(90) == 27)
break;
frameCurrent.copyTo(framePrev);
cap >> frameCurrent;
}
}
OpenCV 错误:输入参数的大小不匹配(操作既不是“数组运算数组”(其中数组具有相同的大小和相同的通道数),也不是“数组运算标量”,也不是“标量运算数组” ') 在 cv::arithm_op,文件 C:\builds\2_4_PackSlave-win64-vc12-shared\opencv\modules\core\src\arithm.cpp,第 1287 行
【问题讨论】: