File tree Expand file tree Collapse file tree 7 files changed +1083
-26
lines changed Expand file tree Collapse file tree 7 files changed +1083
-26
lines changed Original file line number Diff line number Diff line change 13
13
from threading import Thread
14
14
from one_euro_filter import OneEuroFilter
15
15
16
-
17
16
def run_model (self ):
18
17
if self .runtime == "ONNX" or self .runtime == "Default (ONNX)" :
19
18
frame = cv2 .resize (self .current_image_gray , (256 , 256 ))
20
- # make it pil
21
- frame = Image .fromarray (frame )
22
- # make it grayscale
23
- frame = to_grayscale (frame )
24
- # make it a tensor
25
- frame = transforms .ToTensor ()(frame )
26
- # make it a batch
27
- frame = frame .unsqueeze (0 )
28
- # make it a numpy array
29
- frame = frame .numpy ()
30
-
19
+ frame = transforms .ToTensor ()(frame ).unsqueeze (0 ).numpy ()
31
20
out = self .sess .run ([self .output_name ], {self .input_name : frame })
32
21
#end = time.time()
33
22
output = out [0 ]
34
23
output = output [0 ]
24
+
35
25
output = self .one_euro_filter (output )
26
+
36
27
for i in range (len (output )): # Clip values between 0 - 1
37
28
output [i ] = max (min (output [i ], 1 ), 0 )
29
+
38
30
self .output = output
Original file line number Diff line number Diff line change @@ -46,8 +46,8 @@ def __init__(
46
46
fullconfig : "BabbleConfig" ,
47
47
cancellation_event : "threading.Event" ,
48
48
capture_event : "threading.Event" ,
49
- capture_queue_incoming : "queue.Queue" ,
50
- image_queue_outgoing : "queue.Queue" ,
49
+ capture_queue_incoming : "queue.Queue(maxsize=2) " ,
50
+ image_queue_outgoing : "queue.Queue(maxsize=2) " ,
51
51
cam_id ,
52
52
):
53
53
self .main_config = BabbleSettingsConfig
@@ -100,8 +100,8 @@ def __init__(
100
100
beta = float (self .settings .gui_speed_coefficient ) # 0.62
101
101
except :
102
102
print ('\033 [93m[WARN] OneEuroFilter values must be a legal number.\033 [0m' )
103
- min_cutoff = 10.0004
104
- beta = 0.62
103
+ min_cutoff = 0.9
104
+ beta = 0.9
105
105
noisy_point = np .array ([45 ])
106
106
self .one_euro_filter = OneEuroFilter (
107
107
noisy_point ,
Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ def main():
183
183
# GUI Render loop
184
184
while True :
185
185
# First off, check for any events from the GUI
186
- event , values = window .read (timeout = 1 )
186
+ event , values = window .read (timeout = 2 )
187
187
188
188
# If we're in either mode and someone hits q, quit immediately
189
189
if event == "Exit" or event == sg .WIN_CLOSED :
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def __init__(
36
36
cancellation_event : "threading.Event" ,
37
37
capture_event : "threading.Event" ,
38
38
camera_status_outgoing : "queue.Queue[CameraState]" ,
39
- camera_output_outgoing : "queue.Queue" ,
39
+ camera_output_outgoing : "queue.Queue(maxsize=2) " ,
40
40
settings : BabbleSettingsConfig ,
41
41
):
42
42
self .camera_status = CameraState .CONNECTING
@@ -83,7 +83,7 @@ def run(self):
83
83
if (
84
84
self .config .capture_source != None and self .config .capture_source != ""
85
85
):
86
-
86
+ self . current_capture_source = self . config . capture_source
87
87
if ("COM" in str (self .config .capture_source )):
88
88
if (
89
89
self .serial_connection is None
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ class BabbleCameraConfig(BaseModel):
22
22
gui_horizontal_flip : bool = False
23
23
24
24
class BabbleSettingsConfig (BaseModel ):
25
- gui_min_cutoff : str = "10.5004 "
26
- gui_speed_coefficient : str = "0.62 "
25
+ gui_min_cutoff : str = "0.9 "
26
+ gui_speed_coefficient : str = "0.9 "
27
27
gui_osc_address : str = "127.0.0.1"
28
28
gui_osc_port : int = 8888
29
29
gui_osc_receiver_port : int = 9001
You can’t perform that action at this time.
0 commit comments