【opencv】教程代码 —videoio(2)将两个视频的每一帧逐一读取并计算其PSNR 和MSSIM...

本教程开始介绍的源代码将对每一帧执行PSNR测量,并且只对PSNR低于输入值的帧进行SSIM测量。为了可视化的目的,我们在OpenCV窗口中展示两幅图像,并将PSNR和MSSIM值打印到控制台。期望看到如下内容:

16ab19844294d9c88f0cbdb1598fc49e.png

video-input-psnr-ssim.cpp  将两个视频的每一帧逐一读取并计算其峰值信号噪声比(PSNR) 和 结构相似性指标(MSSIM)

4abe1f8f4cde8991df5f902cc8ecfb37.png

#include <iostream> // 标准输入输出流
#include <string>   // 字符串操作库
#include <iomanip>  // 输入输出流格式控制
#include <sstream>  // 字符串与数字转换


#include <opencv2/core.hpp>     // OpenCV基础结构 (cv::Mat, Scalar)
#include <opencv2/imgproc.hpp>  // 高斯模糊处理
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>  // OpenCV窗口输入输出


using namespace std;
using namespace cv;


double getPSNR(const Mat& I1, const Mat& I2); // 声明计算PSNR值的函数
Scalar getMSSIM(const Mat& I1, const Mat& I2); // 声明计算MSSIM值的函数


static void help() // 帮助文本输出函数
{
    cout
        << "------------------------------------------------------------------------------" << endl
        << "This program shows how to read a video file with OpenCV. In addition, it "
        << "tests the similarity of two input videos first with PSNR, and for the frames "
        << "below a PSNR trigger value, also with MSSIM."                                   << endl
        << "Usage:"                                                                         << endl
        << "./video-input-psnr-ssim <re
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值