资源简介
在YUV420中,一个像素点对应一个Y,一个2X2的小方块对应一个U和V。对于所有YUV420图像,它们的Y值排列是完全相同的,因为只有Y的图像就是灰度图像。这个代码可以从YUV视频中提取每一帧画面保存成图片。

代码片段和文件信息
// testDemo.cpp : 定义控制台应用程序的入口点。
//
#include
#include
#include
#include
#include
#include
#include
#include “yuv.h“
using namespace std;
int main()
{
const int YUV_WIDTH=832;
const int YUV_HEIGTH = 480;
string strVideoName = “E:/test/BasketballDrill_832x480_50.yuv“;
string strTxtName = “E:/test/BasketballDrill_832x480_50.txt“;
// cv::VideoCapture myVideoReader(strVideoName.c_str());
struct YUV_Capture myYUVReader;
enum YUV_ReturnValue tmpRet;
FILE *inYUVFile = fopen(strVideoName.c_str() “rb“);
ifstream myTxtReader(strTxtName.c_str());
assert(myTxtReader.is_open());
// open YUV file
tmpRet = YUV_init(inYUVFile YUV_WIDTH YUV_HEIGTH &myYUVReader);
assert(tmpRet == YUV_OK);
string strBuf;
int iVideoIdx = -1;
while(!myTxtReader.eof()){
vector tmpLst(6 0);
for(int iCur=0; iCur<6; iCur++){
myTxtReader >> tmpLst[iCur];
myTxtReader >> strBuf; // for the commm
}
IplImage *bgr = cvCreateImage(cvSize(YUV_WIDTH YUV_HEIGTH) IPL_DEPTH_8U 3);
if(tmpLst[0] != iVideoIdx){
tmpRet = YUV_read(&myYUVReader);
assert(tmpRet == YUV_OK);
cvCvtColor(myYUVReader.ycrcb bgr CV_YCrCb2BGR);
// move to the next frame
iVideoIdx ++;
}
// hold the image frame
cv::Mat inData(bgr);
// get the rectangluar
cv::Rect tmpCU = cv::Rect(cv::Point(tmpLst[1] tmpLst[2]) cv::Size(tmpLst[3] tmpLst[3]));
cv::Mat subMat = inData(tmpCU).clone();
// save the CU image
cv::imwrite(“E:/test/1.jpg“ subMat);
// testing work
cv::imshow(“test“ subMat);
cv::waitKey(0);
}
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 95744 2016-08-18 17:04 testDemo\Debug\testDemo.exe
文件 406 2016-08-18 16:29 testDemo\Debug\testDemo.exe.manifest
文件 682120 2016-08-18 17:04 testDemo\Debug\testDemo.ilk
文件 1649664 2016-08-18 17:04 testDemo\Debug\testDemo.pdb
文件 1254 2016-08-18 17:04 testDemo\testDemo\Debug\cl.command.1.tlog
文件 36142 2016-08-18 17:04 testDemo\testDemo\Debug\CL.read.1.tlog
文件 888 2016-08-18 17:04 testDemo\testDemo\Debug\CL.write.1.tlog
文件 2 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 2 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 2 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 2 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 2 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 2 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 2808 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 3106 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 630 2016-08-18 17:04 testDemo\testDemo\Debug\li
文件 414 2016-08-18 17:04 testDemo\testDemo\Debug\mt.command.1.tlog
文件 264 2016-08-18 17:04 testDemo\testDemo\Debug\mt.read.1.tlog
文件 264 2016-08-18 17:04 testDemo\testDemo\Debug\mt.write.1.tlog
文件 762 2016-08-18 16:29 testDemo\testDemo\Debug\testDemo.Build.CppClean.log
文件 381 2016-08-18 17:04 testDemo\testDemo\Debug\testDemo.exe.intermediate.manifest
文件 58 2016-08-18 17:04 testDemo\testDemo\Debug\testDemo.lastbuildstate
文件 2022 2016-08-18 17:04 testDemo\testDemo\Debug\testDemo.log
文件 305838 2016-08-18 17:04 testDemo\testDemo\Debug\testDemo.obj
文件 707 2016-08-18 16:50 testDemo\testDemo\Debug\testDemo.vcxprojResolveAssemblyReference.cache
文件 0 2016-08-18 16:29 testDemo\testDemo\Debug\testDemo.write.1.tlog
文件 642048 2016-08-18 17:04 testDemo\testDemo\Debug\vc100.idb
文件 937984 2016-08-18 17:04 testDemo\testDemo\Debug\vc100.pdb
文件 91644 2016-08-18 16:51 testDemo\testDemo\Debug\yuv.obj
文件 1766 2016-08-18 17:04 testDemo\testDemo\testDemo.cpp
............此处省略17个文件信息
相关资源
- 将yuv各种格式的图片转换为jpg格式的
- 基于V4L2的视频采集,能够采集YUVJPE
- 最简单的基于FFmpeg的编码器 1.2
- 最简单的基于FFMPEG的视频编码器修正
- 最简单的基于FFmpeg的libswscale的教程
- ( YUV420(YV12)与YUY2(YUV422YUYV)格式
- YUV Viewer 附测试文件格式:yuv420
- qt opengl(after ver2.1) 渲染 nv12
- yuvtools_v2
- libyuv vs2013工程
- JpegToYUV源代码
- 各种格式mp4、wmv、avi、mov等的视频转
- YUV转RGB 的verilog代码
- YUV420文件任意帧指定范围区域截取并
- FFmpeg解码MP4分别播放YUV视频和PCM音频
- YUVTools_3.0_trial.zip
- YUV测试序列:foreman.cif(1-4)
- bmp图片转yuv420
- 7YUV破解版.rar
- YUV视频转换器
- yuv视频文件
-
vooya: raw YUV/RGB Video Pla
yer - YUV颜色空间下成熟苹果识别
-
YUVPla
yer - YUV文件播放工具 - QT使用OpenGL显示YUV420和YUV444数据,内附
- 7YUV 原始图像YUV数据显示播放工具
- yuv转bmp(16位24位32位)工具与vc工程
- yuv图像缩放算法
- v4l2采集+yuyv转yuv420p+h264编码+tcp传输
- YUV444和YUV420互转测试文件
评论
共有 条评论