-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringstream.cpp
More file actions
44 lines (40 loc) · 1.36 KB
/
stringstream.cpp
File metadata and controls
44 lines (40 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*批量读取图片,进行均值滤波处理,并保存至指定目录下*/
/*学习使用stringstream进行图片的批量读取与保存*/
#pragma GCC diagnostic error "-std=c++11"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
using namespace cv;
int main()
{
string imageFileName;
std::stringstream Strm;
int image_count = 14;//图片数量
std::cout << "开始均值滤波处理........" << endl;//便于控制台查看
for (int i = 0; i!= image_count;i++)
{
std::cout << "第"<<i+1<<"张处理成功"<< endl;//便于控制台查看
string filePath = "/home/ttwang/CameraCalibration/chess";//原图保存路径
Strm<< i+1;
Strm>>imageFileName;
filePath+=imageFileName;
filePath+=".bmp";
Mat imageSource = imread(filePath);
Mat newimage = imageSource.clone();
blur(imageSource,newimage,Size(7,7));//均值滤波处理
Strm.clear();
filePath.clear();
string SaveFilePath = "/home/ttwang/CameraCalibration/blur/p";//处理后的图片保存路径
Strm << i+1;
Strm >> imageFileName;
SaveFilePath += imageFileName;
SaveFilePath += "_d.jpg";
imwrite(SaveFilePath,newimage);
}
std::cout << "保存结束" << endl;
return 0;
}