-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinterface.py
More file actions
67 lines (60 loc) · 2.64 KB
/
Copy pathinterface.py
File metadata and controls
67 lines (60 loc) · 2.64 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
import cv2
class Interface:
@staticmethod
def show_main_menu(frame):
main_menu_options = [
"Select Your Choice:",
"1. Arithmetic",
"2. Matrix",
"3. Complex",
"0. Exit"
]
# Determine the width of the longest line to right-align all menu options
text_sizes = [cv2.getTextSize(option, cv2.FONT_HERSHEY_SIMPLEX, 0.8, 2)[0] for option in main_menu_options]
max_width = max([w for (w, h) in text_sizes])
x_pos = frame.shape[1] - max_width - 50 # 50 pixels padding from right edge
y_start = 100 # Starting Y position
line_height = 40 # Space between lines
for i, option in enumerate(main_menu_options):
y_pos = y_start + i * line_height
cv2.putText(frame, option, (x_pos, y_pos), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 2, cv2.LINE_AA)
@staticmethod
def show_matrix_menu(frame):
matrix_menu_options = [
"Select Your Choice:",
"1. Dimension",
"2. Input",
"3. Select",
"4. Operation",
"0. Exit"
]
# Determine the width of the longest line to right-align all menu options
text_sizes = [cv2.getTextSize(option, cv2.FONT_HERSHEY_SIMPLEX, 0.8, 2)[0] for option in matrix_menu_options]
max_width = max([w for (w, h) in text_sizes])
x_pos = 50
y_start = 100 # Starting Y position
line_height = 40 # Space between lines
for i, option in enumerate(matrix_menu_options):
y_pos = y_start + i * line_height
cv2.putText(frame, option, (x_pos, y_pos), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 2, cv2.LINE_AA)
@staticmethod
def show_matrix_operation_menu(frame):
matrix_operation_menu_options = [
"Select Your Choice:",
"1. Addition",
"2. Subtraction",
"3. Multiplication",
"4. Transponse",
"5. Determinant",
"6. Inverse",
"0. Exit"
]
# Determine the width of the longest line to right-align all menu options
text_sizes = [cv2.getTextSize(option, cv2.FONT_HERSHEY_SIMPLEX, 0.8, 2)[0] for option in matrix_operation_menu_options]
max_width = max([w for (w, h) in text_sizes])
x_pos = 50
y_start = 150 # Starting Y position
line_height = 40 # Space between lines
for i, option in enumerate(matrix_operation_menu_options):
y_pos = y_start + i * line_height
cv2.putText(frame, option, (x_pos, y_pos), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 2, cv2.LINE_AA)