多张图像合成视频序列
注意:更改文件名称以及其存放的路径,在sprintf()函数中
#include <opencv2\opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( )
{
const int start_id = 1;
const int end_id = 21;
for (int i = start_id; i <= end_id; i++)
{
char image_path[255];
sprintf(image_path,"./images/%06d.jpg",i);
Mat image = imread(string(image_path));
if (image.empty())
{
cout << "image is empty!" << endl;
break;
}
static VideoWriter my_writer("out.avi", CV_FOURCC('M', 'J', 'P', 'G'), 3.0, Size(image.cols, image.rows));
my_writer << image;
imshow("image", image);
waitKey(1);
}
return 0;
}