以下程序环境为OpenCV2.4.4
#include <iostream>
#include <opencv2/opencv.hpp>
#include <string.h>
#include <fstream>
using namespace std;
using namespace cv;
#define IMAGENUM 116
int main()
{
Mat src;
string ImgName;
char OutName[50];
ifstream fin("handsList.txt"); //handsList.txt为要处理图像的名称列表
for( int framenum=0; framenum<IMAGENUM && getline(fin,ImgName); framenum+=1)
{
cout<<"处理:"<<ImgName<<endl; // 列表给出的为绝对地址,如果只给出图像名称,则需要加上绝对路径(如下)
//ImgName = "E:\\DeepLearning\\testImg\\face\\" + ImgName;
ImgName = ImgName;
src = imread(ImgName,CV_LOAD_IMAGE_UNCHANGED);
sprintf(OutName,"E:\\DeepLearning\\testImg\\v4v5样本版本2\\hands\\%03d.jpg",framenum);//直接以帧数来命名(简单粗暴)
imwrite(OutName, src); //保存重命名之后的图像
}
return 0;
}