#include "stdafx.h"
#include <opencv2\opencv.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\core.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv;
using namespace std;
int main()
{
Mat mat1,mat2,mat3,MAT;
VideoCapture cap(0);
int frameNum = 0;
while(1)
{
cap >> mat2;
//mat2 = Mat(MAT.rows, MAT.cols, CV_8UC1);
//cvtColor(MAT, mat2, COLOR_BGR2GRAY,0);
frameNum++;
if (frameNum == 1) {
mat1 = mat2.clone();
}
absdiff(mat2,mat1,mat3);
threshold(mat3, mat3, 60, 255, CV_THRESH_BINARY);
imshow("camera", mat2);
imshow("moving area", mat3);
mat1 = mat2.clone();
cvWaitKey(1);
}
return 0;
}