opencv批量读图像序列

转自http://www.cnblogs.com/wsc36305/archive/2012/10/19/2731651.html

opencv实现批量读图像序列,以函数的形式实现如下:

  1. void readImageSequenceFiles(char* imgFilePath,vector <string> &imgNames)//用vector <string>做存贮文件名的容器  
  2. {     
  3.     imgNames.clear();  
  4.     int i=0;  
  5.     char tmpDirSpec[MAX_PATH+1];  
  6.     char tmpDirPath[40];  
  7.     sprintf (tmpDirSpec, "%s/*", imgFilePath);//*任意文件名 正则表达式  
  8.   
  9.     WIN32_FIND_DATA f;  
  10.     HANDLE h = FindFirstFile(tmpDirSpec , &f);  
  11.     if(h != INVALID_HANDLE_VALUE)  
  12.     {  
  13.         FindNextFile(h, &f);    //read ..  
  14.         FindNextFile(h, &f);    //read .  
  15.         do  
  16.         {     
  17.             sprintf(tmpDirPath, "%s", imgFilePath);  
  18.               
  19.             imgNames.push_back(f.cFileName);  
  20.             imgNames[i].insert(0,tmpDirPath);  
  21.             i++;  
  22.         } while(FindNextFile(h, &f));  
  23.   
  24.     }  
  25.     FindClose(h);     
  26. }  

主函数里这个调用就可:

  1. char* filefolder="D:/image/chessboards/";  
  2. std::vector <string>  imgname;  
  3.   
  4. readImageSequenceFiles(filefolder,imgname);  

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值