-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
87 lines (73 loc) · 2.04 KB
/
main.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<math.h>
#include<iostream>
#include<string>
#include<sstream>
#include<iomanip>
#include<fstream>
#include"lowPrecise.h"
#include"highPrecise.h"
using namespace std;
using namespace cv;
const string inputpath = "原图\\";//可自行定义图片输入文件夹
const string outputpath = "结果图\\";//输出文件夹
int main() {
string filename;
ifstream lowfile;
ifstream highfile;
vector<string>ALLFILENAMES;//所有文件的名称
vector<string>INPUTPATHS;//所有文件的输入路径
vector<string>OUTPUTPATHS;//所有文件的输出路径
string lowfileopenPath = inputpath + "lowfilenames.txt";
string highfileopenPath = inputpath + "highfilenames.txt";
lowfile.open(lowfileopenPath,ios::in);
highfile.open(highfileopenPath,ios::in);
if (!lowfile||!highfile) {
cerr << "无法打开文件!"<<endl;
exit(0);
}
int count = 0;
while (count<25) {
getline(lowfile, filename, ',');
ALLFILENAMES.push_back(filename);
count++;
}
while (count<29) {
getline(highfile, filename, ',');
ALLFILENAMES.push_back(filename);
count++;
}
for (int i=0;i<29;++i) {
string WindowName = ALLFILENAMES[i];
string inpath = inputpath + WindowName;
string outpath = outputpath + WindowName;
cv::Mat img = imread(inpath);
cv::namedWindow(WindowName,WINDOW_NORMAL);
if (i <= 24) {
lowPreciseDetector ld(img);
ld.showResult();
}
else if(i<=26){
highPreciseDetector hd(img);
hd.showScale1Result();
}
else {
highPreciseDetector hd(img);
hd.showScale2Result();
}
cv::resizeWindow(WindowName, Size(400, 300));
imshow(WindowName, img); cout << setw(20) << setiosflags(ios_base::left) << WindowName << " 已加载";
imwrite(outpath, img); cout <<setw(12)<< setiosflags(ios_base::left) <<" " << " 已写入: " << outpath << endl;
}
std::cout << endl;
std::cout << endl;
std::cout << "按“q”键退出..." << endl;
string c;
int x=waitKey(0);
if ((char)x == 'q') {
destroyAllWindows();
exit(0);
}
return 0;
}