Compare commits

..

No commits in common. "fc0ae3517ebc4a645e7f9b05067d22f87cd81be8" and "d193bdbee3c5b854075c6ec4835fe266b6690729" have entirely different histories.

3 changed files with 35 additions and 71 deletions

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<interface version="1.3"> <interface version="1.3">
<object class="tk.Toplevel" id="main" named="True"> <object class="tk.Toplevel" id="main" named="True">
<property name="geometry">1024x768</property> <property name="geometry">800x600</property>
<property name="height">800</property> <property name="height">800</property>
<property name="title" translatable="yes">Tree Recogniser 7000</property> <property name="title" translatable="yes">Tree Recogniser 7000</property>
<property name="width">200</property> <property name="width">200</property>
@ -231,7 +231,7 @@
<property name="pady">0</property> <property name="pady">0</property>
<property name="selectborderwidth">4</property> <property name="selectborderwidth">4</property>
<property name="setgrid">false</property> <property name="setgrid">false</property>
<property name="state">normal</property> <property name="state">disabled</property>
<property name="takefocus">true</property> <property name="takefocus">true</property>
<property name="text" translatable="yes">Image IDs should appear here</property> <property name="text" translatable="yes">Image IDs should appear here</property>
<property name="width">25</property> <property name="width">25</property>
@ -239,13 +239,13 @@
<layout manager="grid"> <layout manager="grid">
<property name="column">4</property> <property name="column">4</property>
<property name="columnspan">1</property> <property name="columnspan">1</property>
<property name="row">1</property> <property name="row">0</property>
<property name="rowspan">7</property> <property name="rowspan">8</property>
</layout> </layout>
</object> </object>
</child> </child>
<child> <child>
<object class="ttk.LabeledScale" id="s_bright" named="True"> <object class="ttk.LabeledScale" id="brightness_slider" named="True">
<property name="compound">bottom</property> <property name="compound">bottom</property>
<property name="from_">-500</property> <property name="from_">-500</property>
<property name="to">500</property> <property name="to">500</property>
@ -260,7 +260,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="ttk.Label" id="l_bright" named="True"> <object class="ttk.Label" id="brightness_label" named="True">
<property name="text" translatable="yes">Brightness adjust</property> <property name="text" translatable="yes">Brightness adjust</property>
<layout manager="grid"> <layout manager="grid">
<property name="column">0</property> <property name="column">0</property>
@ -270,7 +270,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="ttk.Label" id="l_path" named="True"> <object class="ttk.Label" id="dataset_path_label" named="True">
<property name="text" translatable="yes">Dataset path</property> <property name="text" translatable="yes">Dataset path</property>
<layout manager="grid"> <layout manager="grid">
<property name="column">0</property> <property name="column">0</property>
@ -292,7 +292,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="ttk.Label" id="l_copyright" named="True"> <object class="ttk.Label" id="label2">
<property name="font">TkIconFont</property> <property name="font">TkIconFont</property>
<property name="text" translatable="yes">Powered by ARNweb.nl &amp; TomSelier.com</property> <property name="text" translatable="yes">Powered by ARNweb.nl &amp; TomSelier.com</property>
<layout manager="grid"> <layout manager="grid">
@ -339,50 +339,6 @@
</layout> </layout>
</object> </object>
</child> </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> </object>
</child> </child>
<child> <child>

View File

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

View File

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