This section contains tutorials about how to read/save your video files.
-
Video Input with OpenCV and similarity measurement
Compatibility: > OpenCV 2.0
Author: Bernát Gábor
You will learn how to read video streams, and how to calculate similarity values such as PSNR or SSIM.
-
Compatibility: > OpenCV 2.0
Author: Bernát Gábor
视频输入和相似度测量
-
Video Input with OpenCV and similarity measurement
Compatibility: > OpenCV 2.0
Author: Bernát Gábor
You will learn how to read video streams, and how to calculate similarity values such as PSNR or SSIM.
打开视频:
VideoCapture captRefrnc(sourceReference), captUndTst(sourceCompareWith);
if (!captRefrnc.isOpened())
{
cout << "Could not open reference " << sourceReference << endl;
return -1;
}
if (!captUndTst.isOpened())
{
cout << "Could not open case test " << sourceCompareWith << endl;
return -1;
}
获取视频长宽
Size refS = Size((int) captRefrnc.get(CAP_PROP_FRAME_WIDTH),
(int) captRefrnc.get(CAP_PROP_FRAME_HEIGHT)),
uTSi = Size((int) captUndTst.get(CAP_PROP_FRAME_WIDTH),
(int) captUndTst.get(CAP_PROP_FRAME_HEIGHT));
读取一帧画面
Mat frameReference, frameUnderTest;
。。。
captRefrnc >> frameReference;
captUndTst >> frameUnderTest;
修改图像内容
A read method is made of a frame grab and a decoding applied on that. You may call explicitly these two by using the cv::VideoCapture::grab and then the cv::VideoCapture::retrieve functions
先获取、修改然后应用
图像相似度 Image similarity - PSNR and SSIM
MSE:mean squad error
我认为该叫平均像素差值
Then the PSNR is expressed as:
峰值信噪比
对于一个uchar类型的像素,MAXi就是255
典型的压缩视频PSNR值是30~50,越大效果越好。这种算法(PSNR)比较简单快速,但是与人眼的观察结果并不相同。structural similarity(SSIM)则改正了这个问题。
创建一个视频
-
Compatibility: > OpenCV 2.0
Author: Bernát Gábor
视频内容、音轨、其他轨道如字幕。鉴于OpenCV是一个计算机视觉库,所以只选择了较为简单的avi格式进行支持。因此,2GB的最大文件限制、单轨处理。格式问题自己想办法把。
写视频
搞个对象啦 cv::VideoWriter ,剩下的还要我教你吗?
开始之前可以指定一些参数,通过 cv::VideoWriter::open
写入数据
outputVideo.write(res); //or
outputVideo << res;
多的都是单张图片的处理了。
使用OpenNI兼容传感器
Using Kinect and other OpenNI compatible depth sensors
本来还以为可以打开摄像头了,结果这个并不是。
相关内容看http://blog.csdn.net/augusdi/article/details/8762961