OpenCv 写视频文件

#include "highgui.h"
#include "cv.h"
#include "cxcore.h"
#include "stdio.h"
#include "stdlib.h"


int main(int argc, char* argv[])
{
	CvSize size = cvSize(480, 360);
	double fps = 15;

	CvVideoWriter* writer = cvCreateVideoWriter("F:\\训练加入视频\\aaaa.avi", -1, fps, size); //CV_FOURCC(-1)

	int image_id = 1;
	char filename[256];

	sprintf(filename, "F:\\训练加入视频\\car11\\%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:\\训练加入视频\\car11\\%d.jpg",image_id);
		src = cvLoadImage(filename);

	}

	cvReleaseVideoWriter(&writer); 
	cvReleaseImage(&src_resize);
	cvDestroyWindow("avi");

	return 0;

}

阅读更多
个人分类: OpenCv学习
上一篇OpenCv读取视频时添加一个滚动条
下一篇矩阵维度与通道
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭