我想弄清楚運動檢測如何在opencv中工作。OpenCV cpp運動檢測
我可以看到那裏的視頻分析參考,但我沒有找到足夠的信息如何使用它。
我也看到了一些人使用absdiff我試了一下這樣的,但它給了我在memore錯誤異常
OpenCV Error: Sizes of input arguments do not match (The operation is neither 'a rray op array' (where arrays have the same size and the same number of channels) , nor 'array op scalar', nor 'scalar op array') in cv::arithm_op, file C:\builds \2_4_PackSlave-win32-vc12-shared\opencv\modules\core\src\arithm.cpp, line 1287
代碼
#include <iostream>
#include <sstream>
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main()
{
//create matrix for storage
Mat image;
Mat image2;
Mat image3;
Mat image4;
//initialize capture
VideoCapture cap;
cap.open(0);
//create window to show image
namedWindow("window", 1);
while (1){
//copy webcam stream to image
cap >> image;
cap >> image2;
absdiff(image, image2, image3);
threshold(image3, image4, 128, 255, THRESH_BINARY);
//print image to screen
if (!image.empty()) {
imshow("window", image3);
}
//delay33ms
waitKey(10);
//
}
}
IM顯然不使用它right