- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.cpp
More file actions
Latest commit
199 lines (161 loc) · 6.68 KB
/
Copy pathview.cpp
File metadata and controls
199 lines (161 loc) · 6.68 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#include<iostream>
#include<string>
#include<sstream>
#include<stdlib.h>
#include<opencv2/opencv.hpp>
voidapresentacao() {
std::cout <<" ____ _ _ __ __ ____ " << std::endl;
std::cout <<" / __ \\(_)___ _(_) /_____ _/ / / _/___ ___ ____ _____ ____ " << std::endl;
std::cout <<" / / / / / __ `/ / __/ __ `/ / / // __ `__ \\/ __ `/ __ `/ _ \\" << std::endl;
std::cout <<" / /_/ / / /_/ / / /_/ /_/ / / _/ // / / / / / /_/ / /_/ / __/" << std::endl;
std::cout <<"/_____/_/\\__, /_/\\__/\\__,_/_/ /___/_/ /_/ /_/\\__,_/\\__, /\\___/ "<< std::endl;
std::cout <<" /____/ /____/ " << std::endl;
std::cout <<" .---." << std::endl;
std::cout <<" |[X]|" << std::endl;
std::cout <<" _.==._.\"\"\"\"\".___n__" << std::endl;
std::cout <<" d __ ___.-\'\'-. _____b " << std::endl;
std::cout <<" |[__] /.\"\"\"\".\\ |" << std::endl;
std::cout <<" | // /\"\"\\\\\\ |" << std::endl;
std::cout <<" | \\\\\\__/ // |" << std::endl;
std::cout <<" |pentax\\`.__.\'/ |" << std::endl;
std::cout <<"\\=======`-..-\'======/" << std::endl;
std::cout <<" `-----------------\'" << std::endl;
std::cout <<" ____ _ " << std::endl;
std::cout <<" / __ \\_________ ________ __________(_)___ ____ _" << std::endl;
std::cout <<" / /_/ / ___/ __ \\/ ___/ _ \\/ ___/ ___/ / __ \\/ __ `/" << std::endl;
std::cout <<" / ____/ / / /_/ / /__/ __(__ |__ ) / / / / /_/ / " << std::endl;
std::cout <<" /_/ /_/ \\____/\\___/\\___/____/____/_/_/ /_/\\__, / " << std::endl;
std::cout <<" /____/ " << std::endl;
}
voidmostrarImagens() {
system ("ls images/");
}
std::string perguntarTipoExibicao() {
std::string resp;
std::cout << "\nDeseja aplicar um dos filtros na Webcam ou em uma imagem?" << std::endl;
std::cout << "1) Webcam \n2) Imagem:\nR: ";
while(true) {
std::cin >> resp;
if(resp.compare("1") == 0 || resp.compare("2") == 0) {
break;
}
std::cout << "\nOpcao inválida, por favor reinserir \nR: ";
}
return resp;
}
std::string perguntarQualImagem() {
std::string resp;
std::cout << "\nPor favor, escolha uma das seguintes imagens:" << std::endl;
mostrarImagens();
std::cout << "\nR:";
std::cin >> resp;
return resp;
}
intperguntarQualFiltro() {
int resp;
std::cout << "\nPor favor, escolha um dos filtros disponíveis:" << std::endl;
std::cout << " 1) Cinza Média \n 2) Cinza Ponderado \n 3) Cor Invertida \n 4) Limiarizacao \n 5) Canal de cor isolado";
std::cout << "\n 6) Incrementar Canal de cor \n 7) Zoom In \n 8) Zoom Out \n 9) Somar imagens \n 10) Somar imagens ponderada \n 11) Subtrair imagem \n 12) Histograma";
std::cout << "\n 13) Dilatação \n 14) Erosão \n 15) Abertura \n 16) Fechamento";
std::cout << "\nR: ";
std::cin >> resp;
while(true) {
if(resp >= 1 && resp <= 17) {
break;
}
std::cout << "\nResposta inválida, por favor reeinserir! \nR: ";
std::cin >> resp;
}
return resp;
}
intperguntarValoresSomaPonderadaPrimeiraImagem() {
int valor;
std::cout << "\nPor favor insira o valor(em porcentagem) da primeira imagem \nR: ";
std::cin >> valor;
return (valor >= 0) ? valor : 100;
}
intperguntarValoresSomaPonderadaSegundaImagem() {
int valor;
std::cout << "\nPor favor insira o valor(em porcentagem) da segunda imagem \nR: ";
std::cin >> valor;
return (valor >= 0) ? valor : 100;
}
std::string perguntarQualCor() {
std::string resp;
std::cout << "\n Por favor, insira a cor que deseja: 'R', 'G' ou 'B' \nR: ";
std::cin >> resp;
while(true) {
if(resp.compare("R") == 0 || resp.compare("G") == 0 || resp.compare("B") == 0 ) {
break;
}
std::cout << "Valor inválido inserido, por favor reeinserir! \nR: ";
std::cin >> resp;
}
return resp;
}
intperguntarValorZoom() {
int valor;
std::cout << "Por favor, insira o valor do Zoom In que deseja utilizar \nR: ";
std::cin >> valor;
while(true) {
if(valor > 0) {
break;
}
std::cout << "Valor inválido inserido, por favor reinserir! \nR: ";
std::cin >> valor;
}
return valor;
}
std::string perguntarSegundaImagem() {
std::string resp;
std::cout << "\nPor favor, para a segunda imagem, escolha uma das seguintes: " << std::endl;
mostrarImagens();
std::cout << "\nR:";
std::cin >> resp;
return resp;
}
intperguntarQualValorLimiar() {
int resp;
std::cout << "\nPor favor, insira o valor mínimo de limiar \nR: ";
std::cin >> resp;
return resp;
}
intperguntarTipoAcrescimo() {
int resp = 0;
std::cout << "Por favor, insira o tipo de acrescimo que deseja!\n1) Valor Fixo \n2) Percentual \nR: ";
std::cin >> resp;
return resp;
}
intperguntarValorAcrescimo() {
int resp = 0;
std::cout << "Por favor, insira o valor de acrescimo \nR: ";
std::cin >> resp;
return resp;
}
staticvoidonMouse(int event, int x, int y, int flags, void* param)
{
cv::Mat &image = *((cv::Mat*)param);
if (event == cv::EVENT_LBUTTONDOWN)
{
cv::Vec<unsignedchar, 3>& pixels = image.at<cv::Vec3b>(cv::Point(x,y));
std::cout << "\nB, G, R -> " << pixels << std::endl;
}
}
voidapresentarImagem(cv::Mat image) {
cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE );
cv::imshow("Display Image", image);
cvSetMouseCallback("Display Image", onMouse, &image);
cv::waitKey(0);
}
boolperguntarDesejaIniciarNovamente() {
std::string resp;
std::cout << "\nDeseja iniciar novamente? \n1) Sim\n2) Não \nR: ";
std::cin >> resp;
return (resp.compare("1") == 0);
}
intapresentarVideo(cv::Mat frame) {
cv::namedWindow("Webcam image", cv::WINDOW_AUTOSIZE);
cv::imshow("Webcam image", frame);
cvSetMouseCallback("Webcam image", onMouse, &frame);
returncv::waitKey(30);
}