#include <iostream>
#include <opencv2/opencv.hpp>
#include <string>
using namespace cv;
using namespace std;
int main()
{
string fileName, grayFile;
string str1, str2;
Mat srcImage, grayImage;
for (int i = 0; i <= 10; i++)
{
stringstream ss1, ss2;
ss1 << i;
ss1 >> str1;
//cout << str1 << endl;
fileName = "" + str1 + ".jpg";
srcImage = imread(fileName);
grayFile = "out" + str1 + ".jpg";
cvtColor(srcImage, grayImage, CV_BGR2GRAY);
imwrite(grayFile, grayImage);
}
system("pause");
return 0;
}
其中 stringstream ss1, ss2;这句必须放在for循环中,
c++中批量读取和存入图片
最新推荐文章于 2024-07-29 18:44:05 发布