Skip to content

Commit b7109f2

Browse files
committed
fix config save, fix config load, fix config when check is unchecked
1 parent 12f0d9a commit b7109f2

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

BabbleApp/babble_processor.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import sys
55
import asyncio
66
sys.path.append(".")
7-
from config import BabbleCameraConfig
8-
from config import BabbleSettingsConfig
7+
from config import BabbleCameraConfig, BabbleSettingsConfig, BabbleConfig
98
import queue
109
import threading
1110
import numpy as np
@@ -42,6 +41,7 @@ def __init__(
4241
self,
4342
config: "BabbleCameraConfig",
4443
settings: "BabbleSettingsConfig",
44+
fullconfig: "BabbleConfig",
4545
cancellation_event: "threading.Event",
4646
capture_event: "threading.Event",
4747
capture_queue_incoming: "queue.Queue",
@@ -52,6 +52,7 @@ def __init__(
5252
self.config = config
5353
self.settings = settings
5454
self.eye_id = eye_id
55+
self.config_class = fullconfig
5556
# Cross-thread communication management
5657
self.capture_queue_incoming = capture_queue_incoming
5758
self.image_queue_outgoing = image_queue_outgoing
@@ -270,10 +271,11 @@ def run(self):
270271

271272

272273
run_model(self)
273-
if self.config.use_calibration:
274-
cal.cal_osc(self, self.output)
275-
else:
276-
pass
274+
#if self.config.use_calibration:
275+
cal.cal_osc(self, self.output)
276+
277+
#else:
278+
# pass
277279
#print(self.output)
278280
self.output_images_and_update(self.thresh, CamInfo(self.current_algo, self.output))
279281

BabbleApp/camera_widget.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
5959
self.ransac = EyeProcessor(
6060
self.config,
6161
self.settings_config,
62+
self.main_config,
6263
self.cancellation_event,
6364
self.capture_event,
6465
self.capture_queue,

BabbleApp/osc_calibrate_filter.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def cal_osc(self, array):
3838
# Store the min and max values in the min_max_array
3939
self.min_max_array[0, i] = min_value
4040
self.min_max_array[1, i] = max_value
41-
42-
self.settings.calib_array = self.min_max_array
41+
self.settings.calib_array = np.array2string(self.min_max_array, separator=',')
42+
self.config_class.save()
4343
print("[INFO] Calibration completed.")
4444

4545
PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC)
@@ -55,9 +55,11 @@ def cal_osc(self, array):
5555
# np.append(self.calibrate_config, array.reshape(-1, 1), axis=1)
5656

5757
self.calibration_frame_counter -= 1
58-
varcount = 0
59-
filtered_output = []
60-
if self.settings.calib_array is not None and np.any(self.settings.calib_array):
58+
# print(self.settings.calib_array)
59+
if self.settings.calib_array is not None and self.config.use_calibration:
60+
self.min_max_array = np.fromstring(self.settings.calib_array.replace('[', '').replace(']', ''), sep=',')
61+
self.min_max_array = self.min_max_array.reshape((2, 45))
62+
6163
calibrated_array = np.zeros_like(array)
6264
for i, value in enumerate(array):
6365
min_value = self.min_max_array[0, i]
@@ -70,4 +72,6 @@ def cal_osc(self, array):
7072

7173
calibrated_array[i] = calibrated_value
7274
array = calibrated_array
75+
76+
7377
return array

0 commit comments

Comments
 (0)