mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
Use dacite for de/serialization to python dataclass for config
This commit is contained in:
parent
33ba2ba7d2
commit
92bf069102
@ -1,21 +1,26 @@
|
|||||||
import json
|
from dataclasses import dataclass
|
||||||
|
from typing import Union
|
||||||
|
from dacite import from_dict
|
||||||
import os.path
|
import os.path
|
||||||
|
import json
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class RansacConfig:
|
class RansacConfig:
|
||||||
def __init__(self):
|
threshhold: "int" = 0
|
||||||
self.threshhold = 0
|
rotation_angle: "int" = 0
|
||||||
self.rotation_angle = 0
|
roi_window_x: "int" = 0
|
||||||
self.roi_window_x = 0
|
roi_window_y: "int" = 0
|
||||||
self.roi_window_y = 0
|
roi_window_w: "int" = 640
|
||||||
self.roi_window_w = 640
|
roi_window_h: "int" = 480
|
||||||
self.roi_window_h = 480
|
focal_length: "int" = 30
|
||||||
|
capture_source: "Union[int, str, None]" = 2
|
||||||
|
|
||||||
def load(self):
|
def load():
|
||||||
if not os.path.exists("ransac_settings.json"):
|
if not os.path.exists("ransac_settings.json"):
|
||||||
print("No settings file, using base settings")
|
print("No settings file, using base settings")
|
||||||
return
|
return RansacConfig()
|
||||||
with open("ransac_settings.json", 'r') as settings_file:
|
with open("ransac_settings.json", 'r') as settings_file:
|
||||||
json.load(settings_file)
|
return from_dict(data_class = RansacConfig, data = json.load(settings_file))
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
with open("ransac_settings.json", 'w+') as settings_file:
|
with open("ransac_settings.json", 'w+') as settings_file:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user