-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemoMain.cpp
More file actions
105 lines (103 loc) · 2.71 KB
/
demoMain.cpp
File metadata and controls
105 lines (103 loc) · 2.71 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// Created by pvobile on 17-4-27.
//
#include "demoMain.h"
#include "ImageTraversal/ImageTraversal.h"
#include "ImageComparator/ImageComparator.h"
#include "FileUtils/FileUtils.h"
void DemoMain::showAllModule()
{
for(int i = 0; i < choices.size(); ++ i) {
cout << choices.at(i) << endl;
}
cout << "Your choice: ";
cin >> choice;
}
void DemoMain::filter()
{
cv::Mat image = cv::imread("/home/pvobile/workspace/Cpp/OpenCVDemo/pic/000005OI.jpg");
if (image.data == NULL)
cout << "error\n";
ImgMatchPreFilter filter("/home/pvobile/tmp/match/AdTracker_images/test", "");
filter.run();
}
void DemoMain::traversalTest(int cs)
{
cv::Mat image = cv::imread("/home/pvobile/workspace/Cpp/OpenCVDemo/pic/000005OI.jpg");
if (image.data == NULL)
cout << "error\n";
cv::Mat result;
if(0 == cs )
ImageTraversal::salt(image, 3000);
else if(1 == cs)
ImageTraversal::colorReduce(image);
else if(2 == cs)
ImageTraversal::sharpen(image, result);
cv::namedWindow("test", CV_WINDOW_AUTOSIZE);
cv::imshow("test", image);
cv::waitKey(0);
cv::destroyAllWindows();
cv::destroyAllWindows();
}
void DemoMain::histoTest(int cs)
{
cv::Mat image = cv::imread("/home/pvobile/workspace/Cpp/OpenCVDemo/pic/000005OI.jpg");
if (image.data == NULL)
cout << "error\n";
cv::Mat result;
if(0 == cs)
result = HistoGram1D().getHistoGramImg(image);
else if(1 == cs)
result = HistoGram1D().getBinaryImg(image);
else if(2 == cs)
result = ColorHistoGram().getHistoGramImg(image);
else if(3 == cs)
result = HistoGram1D().stretch(image, 40000);
cv::namedWindow("test", CV_WINDOW_AUTOSIZE);
cv::imshow("test", result);
cv::waitKey(0);
cv::destroyAllWindows();
cv::destroyAllWindows();
}
void DemoMain::contentFinder(int cs)
{
if(0 == cs)
ContentFinder().bpFinderTest();
else if(1 == cs)
ContentFinder().mfFinderTest();
}
void DemoMain::imageComparebyHist()
{
ImageComparator comparator;
cv::Mat image = cv::imread("/share/cvpic/hand1.jpg");
comparator.setReferenceImage(image);
FileUtils utils;
vector<string> files = utils.get_need_files("/share/cvpic", "");
for(auto it : files) {
cv::Mat tmp = cv::imread("/share/cvpic/" + it);
if(tmp.data) {
cout << it << " simalar : " << comparator.compare(tmp) << endl;
}
}
}
void DemoMain::run()
{
showAllModule();
switch (choice)
{
case 0:
filter();
break;
case 1:
traversalTest();
break;
case 2:
histoTest();
break;
case 3:
contentFinder(1);
break;
case 4:
imageComparebyHist();
}
}