forked from eqprog/FF7CCUP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval_image.py
187 lines (148 loc) · 6.15 KB
/
eval_image.py
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
from tkinter import *
import tkinter.ttk as ttk
from PIL import ImageTk, Image
import os
import glob
import initialize_database as tdb
import numpy as np
import evaluator as e
import threading
#import selectFilter as sf
cat_filter = "Foliage"
root = Tk()
root.title("FF7CCUP Evaluator")
root.geometry("1918x1000+0+0")
splash_img = ImageTk.PhotoImage(Image.open("evaluator.png"))
def prev_image(event):
global imgcnt
global imageList
global evaluator
global cat_filter
old_cat=tdb.defineCategory(tdb.get(imageList[imgcnt]))
print("old category: "+old_cat)
tdb.updateRecord(evaluator.write_record(), imageList[imgcnt])
tdb.addDefaultPath(imageList[imgcnt])
new_cat=tdb.defineCategory(tdb.get(imageList[imgcnt]))
print("new category: "+new_cat)
if (old_cat!=new_cat):
tdb.deleteCatRecord(tdb.get(imageList[imgcnt]), old_cat)
tdb.addCatRecord(tdb.get(imageList[imgcnt]), new_cat)
else:
tdb.addCatRecord(tdb.get(imageList[imgcnt]), new_cat)
tdb.organize(tdb.get(imageList[imgcnt]))
tdb.updateInitPath()
imageList = np.asarray(tdb.getImageList(cat_filter))
#tdb.organize(imageList[imgcnt])
if imgcnt > 0:
imgcnt -= 1
tx_attributes=tdb.get(imageList[imgcnt])
evaluator.update_frames(imageList[imgcnt], tx_attributes)
tdb.save(imageList[imgcnt], cat_filter)
#print("#"+str(imgcnt)+": "+imageList[imgcnt])
print("\n")
def next_image(event):
global imgcnt
global imageList
global evaluator
global cat_filter
old_cat=tdb.defineCategory(tdb.get(imageList[imgcnt]))
print("old category: "+old_cat)
tdb.updateRecord(evaluator.write_record(),imageList[imgcnt])
tdb.addDefaultPath(imageList[imgcnt])
new_cat=tdb.defineCategory(tdb.get(imageList[imgcnt]))
print("new category: "+new_cat)
if (old_cat!=new_cat):
tdb.deleteCatRecord(tdb.get(imageList[imgcnt]), old_cat)
tdb.addCatRecord(tdb.get(imageList[imgcnt]), new_cat)
imageList = np.asarray(tdb.getImageList(cat_filter))
else:
tdb.addCatRecord(tdb.get(imageList[imgcnt]), new_cat)
tdb.organize(tdb.get(imageList[imgcnt]))
#tdb.addDefaultPath(imageList[imgcnt])
#tdb.organize(imageList[imgcnt])
tdb.updateInitPath()
if imgcnt < len(imageList)-1:
imgcnt += 1
tx_attributes=tdb.get(imageList[imgcnt])
evaluator.update_frames(imageList[imgcnt], tx_attributes)
tdb.save(imageList[imgcnt], cat_filter)
#print("#"+str(imgcnt)+": "+imageList[imgcnt])
print("\n")
#root.update()
def goButt(category):
print("Go!!!!!")
return category.get()
def main():
#thread=threading.Thread(target=splash_frame)
#thread.start()
#thread.join()
################################################## CREATE WINDOW ###############################################
global root
global imageList
global imgcnt
global evaluator
global cat_filter
splash_img = ImageTk.PhotoImage(Image.open("evaluator.png"))
splashFrame = Frame(root, width = 960)
splashFrame.pack(side=LEFT, anchor=N)
splash_label=Label(splashFrame, image=splash_img)
splash_label.pack(side=TOP, anchor=CENTER)
selection_label=Label(splashFrame, text= "Select a category:")
selection_label.pack(side=TOP, anchor=CENTER)
optionList=["New", "Priority", "Sign/Decal", "Artwork", "Ground", "Wall", "Object/Prop", "Skybox/BG", "NPC", "Enemy", "Foliage",
"Zack - 2nd Class", "Zack - 1st Class", "Zack - Buster Sword", "Aerith", "Cissnei", "Tseng", "Angeal", "Genesis", "Hollander", "Lazard", "Sephiroth", "Cloud", "Tifa", "Yuffie", "Ignore"]
category = StringVar()
goVar=StringVar()
#goVar.set("New")
category.set("New")
#optionconvert = (0, 0, 0, 0, i, 0, 0, 0, 0, 0)
catLabel = OptionMenu(splashFrame, category, *optionList)
catLabel.pack(side=TOP, anchor=CENTER, fill=X)
#goButton = Button(splashFrame, text="GO!", width=100, pady=100, command=category.set(str(goVar.get())))
#goButton.pack(side=BOTTOM)
print("waiting for category selection")
#print(goVar)
catLabel.wait_variable(category)
cat_filter = tdb.defineCategory([0,0,0,0,category.get(),0,0,0,0,0])
print("cat filter: "+cat_filter)
splashFrame.destroy()
tdb.initialize_db()
#tdb.getNewTextures()
################################################## INITIALIZE VARIABLES ########################################
imgcnt=0
#table attributes {filename, givename, width, height, category, text, shinra logo, use esrgan, ignore
imageList = np.asarray(tdb.getImageList(cat_filter))
#print(imageList)
#try:
# tdb.get_save()
#except:
# tdb.save_init(imageList[0])
#finally:
# tdb.get_save()
############################### CHECK IF RECORD EXISTS, IF NOT ADD ENTRY ######################################
sav_pos=np.where(imageList==tdb.get_save(cat_filter))
print(sav_pos[0])
print("\n")
imgcnt=tdb.convertIndex(sav_pos)
tx_attributes=tdb.get(tdb.get_save(cat_filter))
################################################# CREATE LEFT FRAME ###########################################
evaluator = e.Evaluator(root, imageList[imgcnt], tx_attributes)
################################################# DISPLAY ORIGINAL TEXTURE ####################################
evaluator.display_original()
################################################# EVALUATION FRAME ############################################
evaluator.eval_frame()
################################################# DISPLAY UPSCALED ############################################
evaluator.display_upscale()
#navigation buttons VVVVV
button_Prev=Button(evaluator.return_left(), text="Prev")
button_Prev.pack(side=BOTTOM, fill=X)
button_Prev.bind('<Button-1>', prev_image)
root.bind('<Left>', prev_image)
button_Next=Button(evaluator.return_left(), text="Next")
button_Next.pack(side=BOTTOM, fill=X)
button_Next.bind('<Button-1>', next_image)
root.bind('<Right>', next_image)
evaluator.drawOpen()
root.mainloop()
if __name__ == '__main__':
main()