有时我们需要批量读取图片,所以我们有必要知道怎么在OpenCV开源环境下批量读取图片!
批量读取图片的关键是如何让程序知道文件夹下图片的名字!
第一种方法:
这种方法只针对图片名字有规律的情况,比如:
***(0).jpg
***(1).jpg
***(2).jpg
***(3).jpg
..................
源代码如下:
代码中用到的图片下载链接为:http://pan.baidu.com/s/1hr7GUtI 密码:gf7w
//opencv版本:OpenCV3.0
//VS版本:VS2013
//Author:qxsf321.net
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <iostream>
using namespace cv;
using namespace std;
#define NUM 13 //读取image的个数
int main()
{
Mat image;
string ImgName;