c++和opencv实现从一个文件夹读取里面的所有图片和图片名字

#include "opencv.hpp"
#include "opencv.hpp"
#include "opencv.hpp"
#include 
#include 

  std::vector<cv::String> cv_all_img_names;
  cv::glob(FLAGS_image_dir, cv_all_img_names);
  std::cout << "total images num: " << cv_all_img_names.size() << std::endl;

std::vector<cv::Mat> img_list;
  std::vector<cv::String> img_names;
  for (int i = 0; i < cv_all_img_names.size(); ++i) {
    cv::Mat img = cv::imread(cv_all_img_names[i], cv::IMREAD_COLOR);
    if (!img.data) {
      std::cerr << "[ERROR] image read failed! image path: "
                << cv_all_img_names[i] << std::endl;
      continue;
    }
    img_list.push_back(img);//图片列表
    img_names.push_back(cv_all_img_names[i]);//图片名字列表
  }




你可能感兴趣的:(c++,opencv,开发语言)