读取文件夹下所有图像
void ReadImage(const std::string &image_path, std::vector<cv::Mat> &img_rgb_vec,
std::vector<std::string> &image_name_vec) {
std::vector<std::string> image_path_vec;
/// 读取文件夹下所有图像路径
DIR *dir;
if ((dir = opendir(image_path.c_str())) == nullptr) {
throw std::runtime_error("directory " + image_path + " does not exist");
}
dirent *dp;
for (dp = readdir(dir); dp != nullptr; dp = readdir(dir)) {
const std::string img_file_name = dp->d_name;
if (img_file_name == "." || img_file_name == "..") {
continue;
}
image_path_vec.push_back(image_path + "/" + img_file_name);
image_name_vec.push_back(img_file_name);
}
closedir(dir);
std::sort(image_path_vec.begin(), image_path_vec.end());
std::sort(image_name_vec.begin(), image_name_vec.end());
}