配置OpenCV
MFC界面设计
读取指定文件夹下的所有照片
- 在opencv中,命名空间为cv::glob()的函数将pattern路径下的所用文件名存进result中
void cv::glob ( String pattern, std::vector< String > & result, bool recursive = false )
cv::String folder = "res\\my_pic\\"; // 指定照片存储路径
std::vector<cv::String> filenames; // 保存所用文件名
cv::glob(folder, filenames); // 将folders路径下的所用文件名存进filenames中
for (size_t i = 0; i < filenames.size(); ++i)
{
//std::cout << filenames[i] << std::endl;
cv::Mat src = cv::imread(filenames[i]);
if (!src.data)
std::cerr << "Problem loading image!!!" << std::endl;
cv::imshow("temp", src);
cv::waitKey(0);
/* do whatever you want with you