请查看以下代码
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
VideoCapture *camera = new VideoCapture();
camera->open(0);
if(!camera->isOpened())
{
cout << "No Camera" << endl;
return -1;
}
Mat image,blur,image2;
namedWindow("Video");
while(true)
{
*camera>>image;
*camera>>image2;
//Show default image
imshow("Video",image);
if(waitKey(30)>=0)
{
break;
}
}
return 0;
}
我知道如果我设法get the average output of two consecutive frames,我可以将实时网络摄像头输出的视频减少70%。我使用
连续两帧 *camera>>image;
*camera>>image2;
现在,我如何获得平均值并显示它?
请帮忙。
答案 0 :(得分:3)
对于cv::Mat
,你可以这样做:
Mat img_mean=0.5*image+0.5*image2;
imshow("Average",img_mean);