std::stringstream StrStm;
//用以 重载了<>i 的函数
//string StrStm;
string imageFileName;
string filePath = “leo”;
StrStm << i ;
StrStm >> imageFileName;
filePath += imageFileName;
filePath += “.jpg”;
Mat img = imread(filePath);
完整代码
#include <opencv2/opencv.hpp>
#include <iostream>
//#include <string.h>
using namespace std;
using namespace cv;