OpenCV遍历文件夹下图片

#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
using namespace cv;

int getImagePathList(std::string folder, std::vector<cv::String> &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<cv::String> 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;
}

猜你喜欢

转载自blog.csdn.net/weixin_44594953/article/details/122913062