#include<opencv2/opencv.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/core/core.hpp>
using namespace cv;
#include<iostream>
using namespace std;
int main()
{
Mat image;
char filename[1000]; //图片的名称
int isColor = 1; //如果为0 ,可输出灰度图像
int fps = 10; //设置输出视频的帧率
VideoWriter writer("video_out.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'), fps,
Size(500,500), isColor);
for (unsigned int i = 1; i<=193; i++)
{
//我的图片名称是:0001.jpg, ..... 0120.jpg
sprintf(filename, "/home/pi/dwa/%d.jpg", i);
image = imread(filename);//导入图片
if (image.empty())
{
break;
}
//cout << image.channels() << endl; //调试用
//cout << image.size() << endl; //调试用
writer.write(image);
}
writer.release();
return 0;
}