OpenCV读取序列图片(一)

来源:互联网 发布:mac fotor怎么上传图片 编辑:程序博客网 时间:2024/06/09 19:31

看到一篇牛人的博客(http://blog.csdn.net/dengtaocs/article/details/36653597),

发现了长久以来就想解决的问题:OpenCV读取图像序列!太爽了!

比如我的D盘lemming文件夹下有下图所示的图像序列:文件名的宽度为5个字符

每隔5毫秒自动读取下一幅图像直到读取完毕。

#include <iostream>   #include <opencv2/opencv.hpp>   using namespace cv;  using namespace std;    int main()  {      string first_file = "D:/lemming/%5d.jpg";//%5d代表文件名的宽度       VideoCapture sequence(first_file);        Mat image;      namedWindow("Image sequence");        while(1){        sequence >> image;          if(image.empty()) break;          imshow("Image sequence", image);          waitKey(5);//每隔5毫秒再读下一幅图像       }          cout << "End of Sequence" << endl;      waitKey();        return 0;}


 

0 0
原创粉丝点击