OpenCV学习笔记4_ImageToAvi_写视频
ImageToAvi_写视频,将一个系类的图片给组合成一个AVI视频
ImageToAvi.c
/* * Copyright (c++) 2013,合肥学院智能视觉与检测实验室 * All rights reserved. * * 文件名称:ImageToAvi.c * 作 者:高全宁 * 完成日期:2013年5月7日 * *还有点问题,就显示第一张, 思考原因:图片不是一个系列,或者图片太少?? */ #include "stdafx.h" #include "cv.h" #include "highgui.h" #include "cxcore.h" int main() { CvSize size = cvSize(480,360); double fps = 15; CvVideoWriter* writer = cvCreateVideoWriter("F:\\out.avi",-1,fps,size); int image_id = 0; char filename[256]; sprintf(filename,"F:\\image\\%d.jpg",image_id); IplImage* src = cvLoadImage(filename); if (!src) { return 0; } IplImage* src_resize = cvCreateImage(size,8,3); cvNamedWindow("avi"); while(src) { cvShowImage("avi",src_resize); cvWaitKey(1); cvResize(src, src_resize); cvWriteFrame(writer, src_resize); cvReleaseImage(&src); image_id++; sprintf(filename, "F:\\image\\%d.jpg"); src = cvLoadImage(filename); } cvReleaseVideoWriter(&writer); cvReleaseImage(&src_resize); return 0; }
ImageToAvi.cpp
待补
Best Regards To Reader:
==============================================
Royal Kao(高全宁)
Mob: 13771921045
Mail: gaoquanning@163.com
Blog: http://www.cnblogs.com/gaoquanning/
==============================================