#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 写视频文件
最新推荐文章于 2022-04-25 11:06:19 发布