opencv-批量修改文件夹中的图片名

批量修改文件夹中的图片的名字,找了一些程序都不太好用,就自己总结写了一个。

#include
#include

using namespace std;
using namespace cv;

vector RenamePic(cv::String Path);

int main()
{
	cv::String Path = "D://workspace//opencv//Testcode//Testcode//*.jpg";
	vector images = RenamePic(Path);

	return 0;
}

vector RenamePic(cv::String Path)
{
	vector filenames;
	glob(Path, filenames, false);

	vector images;
	size_t count = filenames.size(); 
	for (size_t i = 0; i < count; i++)
	{
		stringstream str;
		str << i << ".jpg";
		string img_path = "D://workspace//opencv//Testcode//Testcode//testimg//";
		imwrite(img_path+str.str(), imread(filenames[i]));
	
	}
	return images;
}

 

你可能感兴趣的:(opencv)