OpenCV遍历文件夹下图片

#include 
#include 
#include 
#include
#include
#include
using namespace std;
using namespace cv;

int getImagePathList(std::string folder, std::vector &imagePathList)
{
    //search all the image in a folder
    cv::glob(folder,imagePathList);
    return 0;
}

int main (int argc,char * argv[]){
   string folder=argv[1];
   std::vector imagePathList;
    getImagePathList(folder,imagePathList);
    for (int i = 0; i < imagePathList.size(); i++)
    {
        std::cout << imagePathList[i] << "\n";
        cv::Mat img = cv::imread(imagePathList[i]);
        cv::imshow("roi", img);
        cv::waitKey(0);
    }
   
    return 0;
}

你可能感兴趣的:(opencv,opencv)