-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_interface.py
More file actions
139 lines (113 loc) · 5.63 KB
/
user_interface.py
File metadata and controls
139 lines (113 loc) · 5.63 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
import sys
import tkinter as tk
import customtkinter as ctk
from tkinter import ttk
from holoElbow_tool_tracking_framework import (tool_tracking_framework_thread)
from functionsScript.UtilityFunctions import (join_reszie_image_same_height)
class camera_user_interface_kinect(tk.Tk):
def __init__(self):
super().__init__()
self.title("HoloElbowComputerVisionModule")
self.start_window()
self.first_start = True
def start_window(self):
for widget in self.winfo_children():
widget.destroy()
self.title("HoloElbow - Computer Vision Module")
start_button = ctk.CTkButton(self, text="HoloElbow - Computer Vision Module ", command=self.app_window)
start_button.pack(pady=10)
line1 = "Master Thesis"
line2 = "Antonio Cangelosi"
line3 = "Giacomo Riberi"
line4 = "Main Supervisor:"
line5 = "Prof. Corrado Cali"
line6 = "Politecnico di Torino"
line7 = "Università Degli Studi di Torino"
label1 = ctk.CTkLabel(self, text=line1, font=('Courier New', 18, 'bold'))
label1.pack(pady=5)
label2 = ctk.CTkLabel(self, text=line2, font=('Courier New', 14, 'italic'))
label2.pack(pady=5)
label3 = ctk.CTkLabel(self, text=line3, font=('Courier New', 14, 'italic'))
label3.pack(pady=5)
label4 = ctk.CTkLabel(self, text=line4, font=('Courier New', 18, 'bold'))
label4.pack(pady=5)
label5 = ctk.CTkLabel(self, text=line5, font=('Courier New', 14, 'italic'))
label5.pack(pady=5)
label6 = ctk.CTkLabel(self, text=line6, font=('Courier New', 14, 'italic'))
label6.pack(pady=5)
label7 = ctk.CTkLabel(self, text=line7, font=('Courier New', 14, 'italic'))
label7.pack(pady=5)
path_logo_poli = "media/politoLogo.png"
path_logo_unito = "media/unitoLogo.jpg"
image_logo = join_reszie_image_same_height(path_logo_poli, path_logo_unito)
panel = tk.Label(self, image=image_logo, text="")
panel.image = image_logo
panel.pack(pady=(10, 20))
def app_window(self):
for widget in self.winfo_children():
widget.destroy()
style = ttk.Style()
style.configure("BW.TLawbel")
self.title("HoloElbowComputerVisionModule")
self.header_label = ttk.Label(self, text="HoloElbow - Computer Vision Module", font=('Courier New', 16, 'bold'))
self.header_label.grid(row=0, column=0,columnspan=3, padx=10, pady=10)
# Video Viewer
self.canvas_video = tk.Label(self)
self.canvas_video.grid(row=7, column=0, columnspan=3,padx=10, pady=10, sticky="nsew")
self.text = tk.Text(self, wrap="word", height=10, width=40)
self.text.grid(row=8, column=0, padx=10, pady=10,columnspan=3)
self.acquire_data_button = tk.BooleanVar()
self.acquire_data_button_1 = ttk.Button(self,
text="Model Acquisition",
command=lambda: (self.acquire_data_button.set(True)),)
self.acquire_data_button_1.grid(row=6, column=2, padx=10, pady=10)
self.ref_frame_tracker_button = tk.BooleanVar()
self.acquire_data_button_1 = ttk.Button(self,
text="Reference Frame Tracker",
command=lambda: (self.ref_frame_tracker_button.set(True)),)
self.acquire_data_button_1.grid(row=6, column=0, padx=10, pady=10)
self.guide_tracker_button = tk.BooleanVar()
self.change_model_button = ttk.Button(self,
text="Guide Tracker",
command=lambda: (self.guide_tracker_button.set(True)),)
self.change_model_button.grid(row=6, column=1, padx=10, pady=10)
self.reset_ref_frame = tk.BooleanVar()
self.reset_ref_frame_button = ttk.Button(self,
text="Reset",
command=lambda: (self.reset_ref_frame.set(True)),)
self.reset_ref_frame_button.grid(row=5, column=0, padx=10, pady=10)
"""
self.start_button = ttk.Button(self,
text="Start",
command=lambda: kinectNavigationSystemThread(self,window=self),)
self.start_button.grid(row=5, column=0, padx=10, pady=10)
"""
self.stop_button_clicked = tk.BooleanVar()
self.stop_button = ttk.Button(self,
text="Stop",
command=lambda: (self.stop_button_clicked.set(True),
self.close_window(self)), )
self.stop_button.grid(row=5, column=1, padx=10, pady=10)
self.save_data = tk.BooleanVar()
self.save_data_button = ttk.Button(self,
text="Data Save",
command=lambda: (self.save_data.set(True)),)
self.save_data_button.grid(row=5, column=2, padx=10, pady=10)
self.cap = None
self.is_running = False
self.thread = None
if self.first_start:
tool_tracking_framework_thread(self,window=self)
self.first_start = False
def update(self):
ret, frame = self.vid.read()
if ret:
self.photo = self.convert_frame(frame)
self.canvas.create_image(0, 0, anchor=tk.NW, image=self.photo)
self.root.after(10, self.update)
def close_window(self, root):
root.destroy()
sys.exit()
if __name__ == "__main__":
he_cvm_app = camera_user_interface_kinect()
he_cvm_app.mainloop()