C++ 如何获得两个连续帧的平均输出?

C++ 如何获得两个连续帧的平均输出?,c++,image,opencv,image-processing,camera,C++,Image,Opencv,Image Processing,Camera,我正在编写以下代码 #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 = ne

我正在编写以下代码

#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;
}

现在,我如何获得平均值并显示它

对于
cv::Mat
,您可以这样做:

Mat img_mean=0.5*image+0.5*image2;
imshow("Average",img_mean);

令人惊叹的。我从来没有想过我可以为相机输出做这么简单的图像操作!有许多矩阵表达式可用。检查一下。
Mat img_mean=0.5*image+0.5*image2;
imshow("Average",img_mean);