OpenCV批量读取路径下所有图片

读取图片路径

#include
#include  
#include

using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
    string dir_path = "F:\\2345Do\\2\\";
    Directory dir;
    string extenttype = "*.jpg";
    vector<string> fileNames = dir.GetListFiles(dir_path, extenttype, false);

    for (int i = 0; i < fileNames.size(); i++)
    {
        //get image name  
        string fileName = fileNames[i];
        string fileFullName = dir_path + fileName;
        cout << "File name:" << fileName << endl;
        cout << "Full path:" << fileFullName << endl;


        /*cv::Mat img = cv::imread(fileFullName);
        cv::imshow("img", img);
        cv::waitKey();*/
    }
    system("pause");
    return 0;

}

OpenCV批量读取路径下所有图片_第1张图片

显示图片

将以上的注释符去掉
OpenCV批量读取路径下所有图片_第2张图片

你可能感兴趣的:(OpenCV)