mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
finish save calib after restart
This commit is contained in:
parent
cbd20fdac8
commit
c1f63dd400
@ -23,6 +23,8 @@ class EyeTrackCameraConfig(BaseModel):
|
|||||||
calib_XMIN: int = None
|
calib_XMIN: int = None
|
||||||
calib_YMAX: int = None
|
calib_YMAX: int = None
|
||||||
calib_YMIN: int = None
|
calib_YMIN: int = None
|
||||||
|
calib_XOFF: int = None
|
||||||
|
calib_YOFF: int = None
|
||||||
|
|
||||||
class EyeTrackSettingsConfig(BaseModel):
|
class EyeTrackSettingsConfig(BaseModel):
|
||||||
gui_flip_x_axis_left: bool = False
|
gui_flip_x_axis_left: bool = False
|
||||||
|
|||||||
@ -13,52 +13,31 @@ class EyeId(IntEnum):
|
|||||||
|
|
||||||
|
|
||||||
class cal():
|
class cal():
|
||||||
# main_config = EyeTrackConfig
|
|
||||||
|
|
||||||
# def __init__(self, main_config: EyeTrackSettingsConfig):
|
|
||||||
# self.settings = main_config
|
|
||||||
|
|
||||||
def cal_osc(self, cx, cy):
|
def cal_osc(self, cx, cy):
|
||||||
svs = False
|
|
||||||
if self.eye_id == EyeId.RIGHT:
|
if self.eye_id == EyeId.RIGHT:
|
||||||
flipx = self.settings.gui_flip_x_axis_right
|
flipx = self.settings.gui_flip_x_axis_right
|
||||||
else:
|
else:
|
||||||
flipx = self.settings.gui_flip_x_axis_left
|
flipx = self.settings.gui_flip_x_axis_left
|
||||||
if self.calibration_frame_counter == 0:
|
if self.calibration_frame_counter == 0:
|
||||||
self.calibration_frame_counter = None
|
self.calibration_frame_counter = None
|
||||||
self.xoff = cx
|
self.config.calib_XOFF = cx
|
||||||
self.yoff = cy
|
self.config.calib_YOFF = cy
|
||||||
self.config.calib_XMAX = self.xmax
|
|
||||||
self.config.calib_YMAX = self.ymax
|
|
||||||
self.config.calib_XMIN = self.xmin
|
|
||||||
self.config.calib_YMIN = self.ymin
|
|
||||||
svs = False
|
|
||||||
# self.settings.save()
|
|
||||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||||
elif self.calibration_frame_counter != None:
|
elif self.calibration_frame_counter != None:
|
||||||
self.settings.gui_recenter_eyes = False
|
self.settings.gui_recenter_eyes = False
|
||||||
if cx > self.xmax:
|
if cx > self.config.calib_XMAX:
|
||||||
self.xmax = cx
|
self.config.calib_XMAX = cx
|
||||||
if cx < self.xmin:
|
if cx < self.config.calib_XMIN:
|
||||||
self.xmin = cx
|
self.config.calib_XMIN = cx
|
||||||
if cy > self.ymax:
|
if cy > self.config.calib_YMAX:
|
||||||
self.ymax = cy
|
self.config.calib_YMAX = cy
|
||||||
if cy < self.ymin:
|
if cy < self.config.calib_YMIN:
|
||||||
self.ymin = cy
|
self.config.calib_YMIN = cy
|
||||||
|
|
||||||
#self.config.calib_XMIN not None and self.config.calib_YMAX
|
|
||||||
self.calibration_frame_counter -= 1
|
self.calibration_frame_counter -= 1
|
||||||
|
|
||||||
if not any(i == None for i in (self.config.calib_XMIN, self.config.calib_YMIN, self.config.calib_XMAX, self.config.calib_YMAX)) and not svs:
|
|
||||||
self.xmax = self.config.calib_XMAX
|
|
||||||
self.ymax = self.config.calib_YMAX
|
|
||||||
self.xmin = self.config.calib_XMIN
|
|
||||||
self.ymin = self.config.calib_YMIN
|
|
||||||
svs = True
|
|
||||||
|
|
||||||
if self.settings.gui_recenter_eyes == True:
|
if self.settings.gui_recenter_eyes == True:
|
||||||
self.xoff = cx
|
self.config.calib_XOFF = cx
|
||||||
self.yoff = cy
|
self.config.calib_YOFF = cy
|
||||||
if self.ts == 0:
|
if self.ts == 0:
|
||||||
self.settings.gui_recenter_eyes = False
|
self.settings.gui_recenter_eyes = False
|
||||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||||
@ -71,16 +50,16 @@ class cal():
|
|||||||
out_x = 0.5
|
out_x = 0.5
|
||||||
out_y = 0.5
|
out_y = 0.5
|
||||||
xl = float(
|
xl = float(
|
||||||
(cx - self.xoff) / (self.xmax - self.xoff)
|
(cx - self.config.calib_XOFF) / (self.config.calib_XMAX - self.config.calib_XOFF)
|
||||||
)
|
)
|
||||||
xr = float(
|
xr = float(
|
||||||
(cx - self.xoff) / (self.xmin - self.xoff)
|
(cx - self.config.calib_XOFF) / (self.config.calib_XMIN - self.config.calib_XOFF)
|
||||||
)
|
)
|
||||||
yu = float(
|
yu = float(
|
||||||
(cy - self.yoff) / (self.ymin - self.yoff)
|
(cy - self.config.calib_YOFF) / (self.config.calib_YMIN - self.config.calib_YOFF)
|
||||||
)
|
)
|
||||||
yd = float(
|
yd = float(
|
||||||
(cy - self.yoff) / (self.ymax - self.yoff)
|
(cy - self.config.calib_YOFF) / (self.config.calib_YMAX - self.config.calib_YOFF)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.settings.gui_flip_y_axis: # check config on flipped values settings and apply accordingly
|
if self.settings.gui_flip_y_axis: # check config on flipped values settings and apply accordingly
|
||||||
@ -105,7 +84,13 @@ class cal():
|
|||||||
if xl > 0:
|
if xl > 0:
|
||||||
out_x = -abs(max(0.0, min(1.0, xl)))
|
out_x = -abs(max(0.0, min(1.0, xl)))
|
||||||
except:
|
except:
|
||||||
print("\033[91m[ERROR] Eye Calibration Invalid!\033[0m")
|
# print("\033[91m[ERROR] Eye Calibration Invalid!\033[0m")
|
||||||
|
self.config.calib_XOFF = 0
|
||||||
|
self.config.calib_YOFF = 0
|
||||||
|
self.config.calib_XMAX = 1
|
||||||
|
self.config.calib_YMAX = 1
|
||||||
|
self.config.calib_XMIN = 1
|
||||||
|
self.config.calib_YMIN = 1
|
||||||
out_x = 0.5
|
out_x = 0.5
|
||||||
out_y = 0.5
|
out_y = 0.5
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user