mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
feat: 3d calibration now can recive both eye's calib points at a single place in calib3d.py
This commit is contained in:
parent
8776c761d8
commit
cc7df74e78
@ -63,6 +63,7 @@ class CameraWidget:
|
||||
self.gui_mask_lighten = f"-LIGHTEN{widget_id}-"
|
||||
self.gui_restart_3d_calibration = f"-RESTART3DCALIBRATION{widget_id}-"
|
||||
|
||||
|
||||
self.last_eye_info = None
|
||||
self.osc_queue = osc_queue
|
||||
self.main_config = main_config
|
||||
|
||||
@ -52,6 +52,8 @@ class EyeTrackCameraConfig(BaseModel):
|
||||
calib_XOFF: Union[float, None] = None
|
||||
calib_YOFF: Union[float, None] = None
|
||||
calibration_points: List[List[Union[float, None]]] = []
|
||||
calibration_points_3d: List[List[Union[float, None]]] = []
|
||||
|
||||
|
||||
|
||||
class EyeTrackSettingsConfig(BaseModel):
|
||||
|
||||
@ -187,6 +187,8 @@ class cal:
|
||||
|
||||
self.calibration_3d_frame_counter = self.calibration_3d_frame_counter - 1
|
||||
overlay_calibrate_3d(self)
|
||||
self.config.calibration_points_3d = []
|
||||
|
||||
|
||||
# print(self.eye_id, cx, cy)
|
||||
# self.settings.gui_3d_calibration = False
|
||||
@ -197,26 +199,27 @@ class cal:
|
||||
self.settings.grab_3d_point = False
|
||||
var.left_calib = False
|
||||
var.right_calib = False
|
||||
print('end')
|
||||
print('end', len(self.config.calibration_points_3d), self.config.calibration_points_3d)
|
||||
|
||||
else:
|
||||
# Check if it's the left eye and left calibration is not done yet
|
||||
if self.eye_id == EyeId.LEFT and not var.left_calib:
|
||||
var.left_calib = True
|
||||
self.config.calibration_points.append((cx, cy, 1))
|
||||
self.config.calibration_points_3d.append((cx, cy, 1))
|
||||
# Check if it's the right eye and right calibration is not done yet
|
||||
elif self.eye_id == EyeId.RIGHT and not var.right_calib:
|
||||
var.right_calib = True
|
||||
self.config.calibration_points.append((cx, cy, 0))
|
||||
self.config.calibration_points_3d.append((cx, cy, 0))
|
||||
|
||||
|
||||
if self.eye_id == EyeId.LEFT and len(self.config.calibration_points) == 8 and var.left_calib == False:
|
||||
if self.eye_id == EyeId.LEFT and len(self.config.calibration_points_3d) == 8 and var.left_calib == False:
|
||||
var.left_calib = True
|
||||
receive_calibration_data(self.config.calibration_points, self.eye_id)
|
||||
receive_calibration_data(self.config.calibration_points_3d, self.eye_id)
|
||||
print('SENT LEFT EYE POINTS')
|
||||
|
||||
if self.eye_id == EyeId.RIGHT and len(self.config.calibration_points) == 8 and var.right_calib == False:
|
||||
if self.eye_id == EyeId.RIGHT and len(self.config.calibration_points_3d) == 8 and var.right_calib == False:
|
||||
var.right_calib = True
|
||||
receive_calibration_data(self.config.calibration_points, self.eye_id)
|
||||
receive_calibration_data(self.config.calibration_points_3d, self.eye_id)
|
||||
print('SENT RIGHT EYE POINTS')
|
||||
# print(len(self.config.calibration_points), self.eye_id)
|
||||
|
||||
|
||||
@ -6,13 +6,15 @@ class CalibrationProcessor:
|
||||
self.right_eye_data = None
|
||||
|
||||
def receive_calibration_data(self, eye_id, data):
|
||||
if eye_id == 'left':
|
||||
if eye_id == 1:
|
||||
self.left_eye_data = data
|
||||
elif eye_id == 'right':
|
||||
elif eye_id == 0:
|
||||
self.right_eye_data = data
|
||||
|
||||
# print('receive',len(self.left_eye_data), self.left_eye_data, self.right_eye_data, data, eye_id)
|
||||
# Check if both sets of data have been received
|
||||
if self.left_eye_data is not None and self.right_eye_data is not None:
|
||||
if len(self.left_eye_data) == 8 and len(self.right_eye_data) == 8:
|
||||
self.process_calibration_data()
|
||||
|
||||
def process_calibration_data(self):
|
||||
@ -27,12 +29,12 @@ class CalibrationProcessor:
|
||||
print(f"Right Eye Data: {self.right_eye_data}")
|
||||
|
||||
# After processing, reset the data
|
||||
self.left_eye_data = None
|
||||
self.right_eye_data = None
|
||||
# self.left_eye_data = None
|
||||
# self.right_eye_data = None
|
||||
|
||||
# Global instance of CalibrationProcessor
|
||||
calibration_processor = CalibrationProcessor()
|
||||
|
||||
def receive_calibration_data(eye_id, data):
|
||||
def receive_calibration_data(data, eye_id):
|
||||
global calibration_processor
|
||||
calibration_processor.receive_calibration_data(eye_id, data)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user