如何得到两个连续帧的平均输出

How to get the average output of two consecutive frames?

本文关键字:连续 输出 两个 何得      更新时间:2023-10-16

我正在编写以下代码

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

我知道如果我设法得到连续两帧的平均输出,我可以将实时网络摄像机输出的视频减少70%。我用

得到了两个连续的帧
            *camera>>image;
            *camera>>image2;

现在,我如何得到它的平均值并显示它呢?

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

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