OpenCV将连续图片合成视频AVI

//功能:将连续图片合成视频AVI
//日期:2016—05-08
//平台:vs2015+opencv3.1
#include
#include
#include

using namespace std;
using namespace cv;

void main()
{
    Mat src=imread("C:\\EXPERIMENT\\眼图照片  (glass)\\wph2\\l0.bmp",1);
    char image_name[50];
    int isColor = 1;
    int fps = 10;
    int frameWidth = src.cols;
    int frameHeight = src.rows;

    VideoWriter writer("C:\\EXPERIMENT\\test_l.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'), fps,
                        Size(frameWidth, frameHeight), isColor);

    cout << "info:" << endl
        << "ff.avi" << endl
        << "Size:" << frameWidth << "*" << frameHeight << endl
        << "fps:" << fps << endl;


    for (int i = 0; i < 1000; i++)
    {
        sprintf(image_name, "C:\\EXPERIMENT\\眼图照片(glass)\\wph2\\l%d.bmp", i);
        src = imread(image_name, 1);
        if (src.empty())
        {
            MessageBox(NULL, L"全部图像加载完成!", L"温馨提示", MB_OK | MB_ICONINFORMATION);
            break;
        }
        imshow("【src】", src);
        waitKey(5);
        writer.write(src);
    }
}

你可能感兴趣的:(opencv学习)