这是我使用 OpenCV 从图像创建视频的示例程序。但是我的输出视频无法正常工作,并且发生错误并指出“无法解复用流”请帮助。
#include<cv.h>
#include<highgui.h>
#include<cvaux.h>
#include<cxcore.h>
int main()
{
//CvVideoWriter *writer = 0;
int isColor = 1;
int fps = 25; // or 30
int frameW = 320; // 744 for firewire cameras
int frameH = 240; // 480 for firewire cameras
CvSize size;
size.width = frameW;
size.height = frameH;
CvVideoWriter *writer = cvCreateVideoWriter(
"data3.avi",
CV_FOURCC('M','J','P','G'),
fps,
size);
IplImage* img = 0;
img=cvLoadImage("IMG_0157.JPG");
for(int counter=0;counter < 3000;counter++)
{
cvWriteFrame(writer,img); // add the frame to the file
}
cvReleaseVideoWriter(&writer);
return 0;
}