opencv3/C++ 将图片转换为视频
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                opencv3/C++ 将图片转换为视频
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                現(xiàn)有一些圖片按順序放置在一文件夾jogging1\下,如圖: 
  
 需要將其合并轉(zhuǎn)換為一個(gè)視頻。
示例:
環(huán)境:Win7+OpenCV3+VS2012
#include<opencv2/opencv.hpp> #include <stdio.h> #include <io.h> #include <string> #include <iostream> #include <fstream> using namespace std; using namespace cv;int main() {_finddata_t FileInfo; //讀取圖片所在的路徑string inPath = "E:\\image\\yu\\jogging1\\"; string strfind = inPath + "*";long Handle = _findfirst(strfind.c_str(), &FileInfo);char filename[300];Mat src;if (Handle == -1L){ cerr << "can not match the folder path" << endl; exit(-1);}Mat frame;Mat src0 = imread("E:/image/yu/jogging1/0000.jpg");Size size = src0.size();VideoWriter writer;writer.open("jogging.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25, size, true);do{//判斷是否有子目錄if (FileInfo.attrib & _A_SUBDIR) { if ((strcmp(FileInfo.name, ".") != 0) && (strcmp(FileInfo.name, "..") != 0)) { inPath += FileInfo.name;cout <<inPath<<endl; }}else{cout <<inPath<<FileInfo.name<<endl;//讀取圖片所在的路徑string path = "E:/image/yu/jogging1/" + (string)FileInfo.name;src = imread(path);imshow("input", src);writer.write(src);waitKey(1);} } while (_findnext(Handle, &FileInfo) == 0); _findclose(Handle); return 0; }總結(jié)
以上是生活随笔為你收集整理的opencv3/C++ 将图片转换为视频的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
                            
                        - 上一篇: 微信平台开发教程
 - 下一篇: 【概率论】伯努利分布 Bernoulli