-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
165 lines (137 loc) · 5.83 KB
/
Copy pathapp.py
File metadata and controls
165 lines (137 loc) · 5.83 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
from tkinter import *
from modules.extracao_de_caracteristicas import Extract
from modules.aprendizagem_bayesiana import AprendizagemBayesiana
from tkinter.filedialog import askopenfilename
import os
# extensao arff
import arff
class Application:
def __init__(self, master=None):
self.fonte = ("Verdana", "12")
# Container de Botões
self.container1 = Frame(master)
self.container1["pady"] = 20
self.container1.pack()
# Botão Extrair Características
self.btnExtract = Button(self.container1, text="Extrair Características",
font=self.fonte, width=20 )
self.btnExtract["command"] = self.extract
self.btnExtract.pack(side=LEFT)
# Botão Selecionar Imagem
self.btnSelect = Button(self.container1, text="Selecionar Imagem",
font=self.fonte, width=20)
self.btnSelect["command"] = self.select_image
self.btnSelect.pack(side=LEFT)
# Botão Selecionar Imagem
self.btnClassify = Button(self.container1, text="Classificar",
font=self.fonte, width=20)
self.btnClassify["command"] = self.classify
self.btnClassify.pack(side=RIGHT)
# Container de Imagens
self.container2 = Frame(master)
self.container2["pady"] = 10
self.container2["padx"] = 5
self.container2.pack(side=LEFT)
# Container de Classificação
self.container3 = Frame(master)
self.container3["pady"] = 10
self.container3["padx"] = 5
self.container3.pack(side=RIGHT)
# self.container3.grid(row=1, column=1)
self.container4 = Frame(master)
self.container3["pady"] = 10
self.container3["padx"] = 5
self.container4.pack(side=LEFT)
self.container5 = Frame(master)
self.container3["pady"] = 10
self.container3["padx"] = 5
self.container5.pack(side=LEFT)
self.container6 = Frame(master)
self.container6.pack(side=RIGHT)
self.container7 = Frame(master)
self.container7.pack(side=RIGHT)
self.container8 = Frame(master)
self.container8.pack(side=RIGHT)
# self.lblfeatures = Label(self.container3, text="Características",
# font=22, justify=CENTER)
# self.lblfeatures.pack(side=TOP)
#
self.lblapu = Label(self.container4, text="APU: ",
font=22, justify=CENTER)
self.lblapu.pack(side=LEFT)
#
self.lblapupercent = Label(self.container4, text="",
font=22, justify=CENTER)
self.lblapupercent.pack(side=LEFT)
#
# self.lblapufeaturetwo = Label(self.container6, text="Cor da Jaqueta",
# font=22, justify=CENTER)
# self.lblapufeaturetwo.pack(side=LEFT)
#
# self.lblapufeaturethree = Label(self.container7, text="Cor da Calça",
# font=22, justify=CENTER)
# self.lblapufeaturethree.pack(side=LEFT)
#
self.lblnelson = Label(self.container5, text="NELSON: ",
font=22, justify=CENTER)
self.lblnelson.pack(side=LEFT)
#
self.lblnelsonpercent = Label(self.container5, text="",
font=22, justify=CENTER)
self.lblnelsonpercent.pack(side=RIGHT)
#
# self.lblnelsonfeaturetwo = Label(self.container6, text="Cor do Colete",
# font=22, justify=CENTER)
# self.lblnelsonfeaturetwo.pack(side=LEFT)
#
# self.lblnelsonfeaturethree = Label(self.container7, text="Cor da Camisa",
# font=22, justify=CENTER)
# self.lblnelsonfeaturethree.pack(side=LEFT)
# self.lbloriginal = Label(self.container2, text="Imagem Original",
# font=22, justify=CENTER )
# self.lbloriginal.pack(side=TOP)
# self.lblprocessed = Label(self.container3, text="Imagem Processada",
# font=22 )
# self.lblprocessed.pack(side=TOP)
#
# self.imgoriginal = PhotoImage(file="images/img.png")
# self.lblimage1 = Label(self.container2, image=self.imgoriginal).pack()
def extract(self):
# carregando a imagem
data = []
# Carregando a lista de Imagens
images = os.listdir('images/coaching')
for img in images:
data += [Extract.extract_feature('images/coaching/' + img, False)]
# gerando arquivo .arrf
attributes = [
'cor_da_pele_Apu',
'cor_da_jaqueta_Apu',
'cor_da_calca_Apu',
'cor_da_pele_nelson',
'cor_do_colete_nelson',
'cor_da_camisa_nelson',
'classe {Apu, Nelson}'
]
try:
arff.dump('caracteristicas.arff', data, relation="caracteristicas", names=attributes)
except NameError:
print('error', NameError)
def select_image(self):
Tk().withdraw()
filename = askopenfilename()
img_extracted_features = Extract.extract_feature(filename, True)
img_extracted_features.pop(6)
def classify(self):
Tk().withdraw()
filename = askopenfilename()
img_extracted_features = Extract.extract_feature(filename, False)
img_extracted_features.pop(6)
# print("Caracterisiticas" ,img_extracted_features)
classification = AprendizagemBayesiana.bayes_classifier(img_extracted_features)
self.lblapupercent["text"] = str(round(classification[0]*100, 2)) + " % "
self.lblnelsonpercent["text"] = str(round(classification[1]*100, 2)) + " %"
root = Tk()
Application(root)
root.mainloop()
# Plot normal and equalized image