This commit is contained in:
Arne van Iterson 2023-10-04 14:45:17 +02:00
parent 468f62633c
commit a509b648ed
3 changed files with 71 additions and 35 deletions

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<interface version="1.3">
<object class="tk.Toplevel" id="main" named="True">
<property name="geometry">800x600</property>
<property name="geometry">1024x768</property>
<property name="height">800</property>
<property name="title" translatable="yes">Tree Recogniser 7000</property>
<property name="width">200</property>
@ -231,7 +231,7 @@
<property name="pady">0</property>
<property name="selectborderwidth">4</property>
<property name="setgrid">false</property>
<property name="state">disabled</property>
<property name="state">normal</property>
<property name="takefocus">true</property>
<property name="text" translatable="yes">Image IDs should appear here</property>
<property name="width">25</property>
@ -239,13 +239,13 @@
<layout manager="grid">
<property name="column">4</property>
<property name="columnspan">1</property>
<property name="row">0</property>
<property name="rowspan">8</property>
<property name="row">1</property>
<property name="rowspan">7</property>
</layout>
</object>
</child>
<child>
<object class="ttk.LabeledScale" id="brightness_slider" named="True">
<object class="ttk.LabeledScale" id="s_bright" named="True">
<property name="compound">bottom</property>
<property name="from_">-500</property>
<property name="to">500</property>
@ -260,7 +260,7 @@
</object>
</child>
<child>
<object class="ttk.Label" id="brightness_label" named="True">
<object class="ttk.Label" id="l_bright" named="True">
<property name="text" translatable="yes">Brightness adjust</property>
<layout manager="grid">
<property name="column">0</property>
@ -270,7 +270,7 @@
</object>
</child>
<child>
<object class="ttk.Label" id="dataset_path_label" named="True">
<object class="ttk.Label" id="l_path" named="True">
<property name="text" translatable="yes">Dataset path</property>
<layout manager="grid">
<property name="column">0</property>
@ -292,7 +292,7 @@
</object>
</child>
<child>
<object class="ttk.Label" id="label2">
<object class="ttk.Label" id="l_copyright" named="True">
<property name="font">TkIconFont</property>
<property name="text" translatable="yes">Powered by ARNweb.nl &amp; TomSelier.com</property>
<layout manager="grid">
@ -339,6 +339,50 @@
</layout>
</object>
</child>
<child>
<object class="tk.Text" id="testdata" named="True">
<property name="height">15</property>
<property name="text" translatable="yes">No tests have been run yet</property>
<property name="undo">false</property>
<property name="width">25</property>
<property name="wrap">word</property>
<layout manager="grid">
<property name="column">5</property>
<property name="columnspan">1</property>
<property name="row">1</property>
<property name="rowspan">7</property>
</layout>
</object>
</child>
<child>
<object class="ttk.Label" id="l_meta" named="True">
<property name="text" translatable="yes">Metadata</property>
<layout manager="grid">
<property name="column">4</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="ttk.Label" id="l_tests" named="True">
<property name="text" translatable="yes">Test results</property>
<layout manager="grid">
<property name="column">5</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="ttk.Button" id="tests" named="True">
<property name="text" translatable="yes">Run Tests</property>
<layout manager="grid">
<property name="column">02</property>
<property name="columnspan">2</property>
<property name="ipadx">68</property>
<property name="row">6</property>
</layout>
</object>
</child>
</object>
</child>
<child>

View File

@ -45,5 +45,4 @@ class Logger:
self.data = []
def __del__(self):
print("Log file closed!")
self.file.close()

View File

@ -88,8 +88,6 @@ class MainApp:
"""
Close PLT windows on main app quit
"""
# TODO: This function runs multiple times for some reason
if plt is not None:
plt.close() # Close graph vies
log.file.close() # Close log files
@ -137,13 +135,6 @@ class MainApp:
# Update UI
self.update(self)
"""
TODO:
- Primitive surface area
- Derivative max x and y pos
- Function min, max + y position
"""
def apply(self, event=None, path=None):
"""
Export current dataset
@ -280,23 +271,22 @@ class MainApp:
y_ind = (int)(th1 / canny_step)
x_ind = (int)(th2 / canny_step)
# Ignore all edges where th1 > th2
if th1 <= th2:
# Canny Edge Detection
edges = cv2.Canny(image=img, threshold1=th1, threshold2=th2)
w_res = cv2.countNonZero(edges)
results[y_ind].append(w_res)
else:
results[y_ind].append(0)
# Canny Edge Detection
edges = cv2.Canny(image=img, threshold1=th1, threshold2=th2)
w_res = cv2.countNonZero(edges)
results[y_ind].append(w_res)
# print(f"Result at thres {th1}, {th2}; \tIndex {y_ind}, {x_ind} \t= {w_res}")
# print(results[y_ind])
func = np.diag(results)
diff = np.diff(func)
area = sum(func)
self.axs[column, row - 1].clear()
self.axs[column, row - 1].title.set_text("Canny F U N C")
self.axs[column, row - 1].title.set_text(F"Area: {area}")
self.axs[column, row - 1].plot(func)
self.axs[column, row - 1].plot(np.diff(func))
self.axs[column, row - 1].plot(diff)
self.axs[column, row].title.set_text(
f"Mean: {np.matrix(results).mean()}\nStd: {np.matrix(results).std()}"
@ -309,12 +299,15 @@ class MainApp:
lambda x, pos: str(x * canny_step)
)
log.add("Canny Mean", np.matrix(results).mean())
log.add("Canny Std", np.matrix(results).std())
log.add("Canny Min", np.matrix(results).min())
log.add("Canny Max", np.matrix(results).max())
log.add("Canny Diff min", np.diff(func).min())
log.add("Canny Diff max", np.diff(func).max())
log.add("Canny Mean", func.mean())
log.add("Canny Std", func.std())
log.add("Canny Min", func.min())
log.add("Canny Max x", np.where(func==func.max())[0][0])
log.add("Canny Max y", func.max())
log.add("Canny Diff max y", diff.max())
log.add("Canny Diff min x",np.where(diff==diff.min())[0][0])
log.add("Canny Diff min y", diff.min())
log.add("Canny Area", area)
def writeStats(self, img, labels, column, row):
mean, std = imgStats(img)
@ -379,7 +372,7 @@ class MainApp:
print("Full update forced!")
if self.updatePath():
log.add("Img", self.img_name)
log.add("Tree", self.img_name.split("_")[0])
# Get all user vars
ct1 = self.canny_thr1.get()