#include"stdafx.h"
#include"opencv2\highgui\highgui.hpp"
#include"opencv2\imgproc\imgproc.hpp"
#include"opencv2\core\core.hpp"
#include"iostream"
using namespace cv;
using namespace std;
Mat frame;//当前帧
Mat gray,prev_gray;
Mat result;//输出
int main(){
VideoCapture capture("F:\\实验视频\\unwrap.avi");
if(capture.isOpened())
{
while(true)
{
capture >> frame;
if(!frame.empty())
{
cvtColor(frame, gray, CV_BGR2GRAY);
if(prev_gray.empty()){
gray.copyTo(prev_gray);
}
absdiff(gray,prev_gray,result);
imshow("result",result);
swap(prev_gray,gray);
}
else
{
printf(" --(!) No captured frame -- Break!");
break;
}
int c = waitKey(100);
if( (char)c == 27 )
{
break;
}
}
}
}
帧间差
最新推荐文章于 2021-03-05 10:05:00 发布