#include 赞 踩 从文件夹中读取所有图片(图片序号可以是乱序): Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。
C++ 从文件夹中批量读取图片_c++ 读取文件夹下所有图片
#include "iostream"
#include "fstream"
#include <string>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\opencv.hpp>
using namespace cv;
using namespace std;
void()
{
//从文件夹中读取所有图片(图片序号可以是乱序)
String pattern = "C:\\Users\\Admin\\Desktop\\数据\\*.jpg";
vector<string> img_path;
vector<cv::String> fn;
glob(pattern, fn, false);
size_t count = fn.size(); //number of png files in images folder
for (size_t i = 0; i < count; i++)
{
img_path.push_back(fn[i]);
}
Mat frame;
for (int i = 0; i < img_path.size(); i++)
{
frame = imread(img_path[i]);
if (frame.data == NULL)
break;
}
}