// OpencvDirTraverse.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
string dir_path = "D:/images/all_0407/";
Directory dir;
vector<string> fileNames = dir.GetListFiles(dir_path, "*.jpg", false);
for(int i=0; i < fileNames.size(); i++)
{
string fileName = fileNames[i];
string fileFullName = dir_path + fileName;
cout<<"file name:"<<fileName<<endl;
cout<<"file paht:"<<fileFullName<<endl;
}
system("pause");
return 0;
}
//
#include "stdafx.h"
#include <iostream>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
string dir_path = "D:/images/all_0407/";
Directory dir;
vector<string> fileNames = dir.GetListFiles(dir_path, "*.jpg", false);
for(int i=0; i < fileNames.size(); i++)
{
string fileName = fileNames[i];
string fileFullName = dir_path + fileName;
cout<<"file name:"<<fileName<<endl;
cout<<"file paht:"<<fileFullName<<endl;
}
system("pause");
return 0;
}
主要就是利用Directory这个类,里面有封装好的getlistfile函数,能够遍历文件夹下面所有文件。