level 2
iqpkfred
楼主
#include<opencv2\opencv.hpp>
#include "opencv2/core/core.hpp"
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
using namespace cv;
int main()
{
string videoFile = "4.avi";
VideoCapture capture;
capture.open(videoFile);
if (!capture.isOpened())
{
cout << "read video failure" << std::endl;
return -1;
}
BackgroundSubtractorMOG2* mog = createBackgroundSubtractorMOG2();
Mat foreground;
Mat background;
Mat frame;
long frameNo = 0;
while (capture.read(frame))
{
mog->apply(frame, foreground);
mog->getBackgroundImage(background); // 返回当前背景图像
imshow("video", foreground);
imshow("background", background);
system("pause");
if (waitKey(25) > 0)
{
break;
}
}
return 0;
}
2015年04月14日 16点04分
1
#include "opencv2/core/core.hpp"
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
using namespace cv;
int main()
{
string videoFile = "4.avi";
VideoCapture capture;
capture.open(videoFile);
if (!capture.isOpened())
{
cout << "read video failure" << std::endl;
return -1;
}
BackgroundSubtractorMOG2* mog = createBackgroundSubtractorMOG2();
Mat foreground;
Mat background;
Mat frame;
long frameNo = 0;
while (capture.read(frame))
{
mog->apply(frame, foreground);
mog->getBackgroundImage(background); // 返回当前背景图像
imshow("video", foreground);
imshow("background", background);
system("pause");
if (waitKey(25) > 0)
{
break;
}
}
return 0;
}
