图像序列合成视频(vs2013+opencv)

#include
#include

using namespace std;
using namespace cv;

int main()
{
	CvVideoWriter *writer = 0;
	int isColor = 1;
	int fps = 30;  
	int frameW = 640; 
	int frameH = 480; 
	writer = cvCreateVideoWriter("out.avi", CV_FOURCC('D', 'I', 'V', 'X'),
		fps, cvSize(frameW, frameH), isColor);


	IplImage* img = 0;
	for (int i = 0; i<544; i++){

		char tmpName[300];
		sprintf(tmpName, "D:/TT/%d.jpg", i);

		img = cvLoadImage(tmpName);

		if (img == NULL)continue;

		cvWriteFrame(writer, img);      // add the frame to the file

		cvReleaseImage(&img);
	}
	cvReleaseVideoWriter(&writer);
	return 0;
}

你可能感兴趣的:(opencv)