簡介:
將連續的圖片轉換成視頻時,首先需要把圖片全部讀入,然后再做相應處理,該程序利用sprintf()函數,實現連續圖片的讀入
/*********新建QT控制台程序,實現多張連續圖片的讀取*********/ /******************2017年12月9日******************/ 源代碼如下: #include <QCoreApplication> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <iostream> using namespace std; using namespace cv; int main() { char filename[76]; //定義數組,其中數組大小等於圖片的個數 Mat image; for(unsigned int i=0;i<76;i++) { sprintf(filename,"/home/ttwang/images/image%d.jpg",i);//第二個參數是指定圖片路徑和圖片名的一般式(image%d) image=imread(filename);//導入圖片 imshow("image",image); waitKey(0); } }