读取文件夹中所有文件:glob函数

1、glob函数:
glob在opencv3下,并且命名空间为cv::glob()能够直接调用,函数将pattern路径下的所有文件名存进result中,返回一个包含匹配指定模式的文件名或目录的数组

void cv::glob ( String pattern,
std::vector< String > & result,
bool recursive = false
)

2、读取文件夹中所有图像

std::vectorcv::String filenames; // notice here that we are using the Opencv’s embedded “String” class
cv::String folder = “/home/***”; // again we are using the Opencv’s embedded “String” class
cv::glob(folder, filenames); // new function that does the job

注意!
路径一定要正确,区分大小写

猜你喜欢

转载自blog.csdn.net/weixin_41169280/article/details/110138193