diff --git a/BabbleApp/babble_processor.py b/BabbleApp/babble_processor.py index ce887c6..247f16d 100644 --- a/BabbleApp/babble_processor.py +++ b/BabbleApp/babble_processor.py @@ -4,8 +4,7 @@ from dataclasses import dataclass import sys import asyncio sys.path.append(".") -from config import BabbleCameraConfig -from config import BabbleSettingsConfig +from config import BabbleCameraConfig, BabbleSettingsConfig, BabbleConfig import queue import threading import numpy as np @@ -42,6 +41,7 @@ class EyeProcessor: self, config: "BabbleCameraConfig", settings: "BabbleSettingsConfig", + fullconfig: "BabbleConfig", cancellation_event: "threading.Event", capture_event: "threading.Event", capture_queue_incoming: "queue.Queue", @@ -52,6 +52,7 @@ class EyeProcessor: self.config = config self.settings = settings self.eye_id = eye_id + self.config_class = fullconfig # Cross-thread communication management self.capture_queue_incoming = capture_queue_incoming self.image_queue_outgoing = image_queue_outgoing @@ -270,10 +271,11 @@ class EyeProcessor: run_model(self) - if self.config.use_calibration: - cal.cal_osc(self, self.output) - else: - pass + #if self.config.use_calibration: + cal.cal_osc(self, self.output) + + #else: + # pass #print(self.output) self.output_images_and_update(self.thresh, CamInfo(self.current_algo, self.output)) diff --git a/BabbleApp/camera_widget.py b/BabbleApp/camera_widget.py index 9631ade..beab024 100644 --- a/BabbleApp/camera_widget.py +++ b/BabbleApp/camera_widget.py @@ -59,6 +59,7 @@ class CameraWidget: self.ransac = EyeProcessor( self.config, self.settings_config, + self.main_config, self.cancellation_event, self.capture_event, self.capture_queue, diff --git a/BabbleApp/osc_calibrate_filter.py b/BabbleApp/osc_calibrate_filter.py index 1b7efc2..5baf0fe 100644 --- a/BabbleApp/osc_calibrate_filter.py +++ b/BabbleApp/osc_calibrate_filter.py @@ -38,8 +38,8 @@ class cal(): # Store the min and max values in the min_max_array self.min_max_array[0, i] = min_value self.min_max_array[1, i] = max_value - - self.settings.calib_array = self.min_max_array + self.settings.calib_array = np.array2string(self.min_max_array, separator=',') + self.config_class.save() print("[INFO] Calibration completed.") PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC) @@ -55,9 +55,11 @@ class cal(): # np.append(self.calibrate_config, array.reshape(-1, 1), axis=1) self.calibration_frame_counter -= 1 - varcount = 0 - filtered_output = [] - if self.settings.calib_array is not None and np.any(self.settings.calib_array): + # print(self.settings.calib_array) + if self.settings.calib_array is not None and self.config.use_calibration: + self.min_max_array = np.fromstring(self.settings.calib_array.replace('[', '').replace(']', ''), sep=',') + self.min_max_array = self.min_max_array.reshape((2, 45)) + calibrated_array = np.zeros_like(array) for i, value in enumerate(array): min_value = self.min_max_array[0, i] @@ -70,4 +72,6 @@ class cal(): calibrated_array[i] = calibrated_value array = calibrated_array + + return array \ No newline at end of file