-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminal.py
89 lines (69 loc) · 2.35 KB
/
terminal.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
"""Utility functions to print/prompt data in terminal."""
def print_det_time(count, ir_sns, cmr, start, delay):
"""Print detection time into terminal/console.
Args:
count: detection count
ir_sns: ir sensor detection time
cmr: camera detection time
start: start detection time
delay: delay between detection
"""
rounded_irs = round((ir_sns - start), 3)
rounded_cmr = round((cmr - start), 3)
rounded_dly = round(delay, 3)
print(f"Detection Session: {count}")
print(f"IR sensor detection at {rounded_irs} second")
print(f"Camera detection at {rounded_cmr} second")
print(f"Delay between detections: {rounded_dly} second")
def print_detected(name, score):
"""Print messages if object is detected.
Args:
name: name of detected object
score: probability score
"""
print(f"The object is {name}")
print(f"The probability is {score}")
def print_undetected(count):
"""Print messages if nothing is detected.
Args:
count: detection count
"""
print(f"Detection Session: {count}")
print("Object is not detected!")
def print_dimension(dimension, score):
"""Print messages about detected dimension.
Args:
dimension: detected dimension of object
score: probability score of an object
"""
print("Dimension:")
print(f"The height is {dimension[0]} cm")
print(f"The width is {dimension[1]} cm")
print(f"The size/area is {dimension[2]} cm2")
print(f"Probability: {score}")
def print_color(color, score):
"""Print messages if object is detected.
Args:
color: BGR tuple of detected object
score: probability score
"""
print(f"The BGR color is {color}")
print(f"The probability is {score}")
def prompt_label():
"""Prompt user to input the true label."""
true_label = str(input("True label of the object: "))
atuple = tuple(true_label.strip("()").split(","))
if len(atuple) == 1:
return atuple[0]
else:
return (
int(round(float(atuple[0]))),
int(round(float(atuple[1]))),
int(round(float(atuple[2]))),
)
def prompt_type():
"""Prompt user to input the true label."""
print("For traditional method, detection type has to be shape or color")
det_type = str(input("Detection Type: "))
print("")
return det_type