mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
Merge branch 'HSF-and-new-algos-feature-branch' of https://github.com/RedHawk989/EyeTrackVR into HSF-and-new-algos-feature-branch
This commit is contained in:
commit
5ec32e5b96
@ -9,8 +9,7 @@ from camera import Camera, CameraState
|
||||
from osc import EyeId
|
||||
import cv2
|
||||
import sys
|
||||
if sys.platform.startswith("win"):
|
||||
from winsound import PlaySound, SND_FILENAME, SND_ASYNC
|
||||
from utils.misc_utils import PlaySound,SND_FILENAME,SND_ASYNC
|
||||
import traceback
|
||||
import numpy as np
|
||||
|
||||
@ -243,8 +242,7 @@ class CameraWidget:
|
||||
|
||||
if event == self.gui_restart_calibration:
|
||||
self.ransac.calibration_frame_counter = 300
|
||||
if sys.platform.startswith("win"):
|
||||
PlaySound('Audio/start.wav', SND_FILENAME | SND_ASYNC)
|
||||
PlaySound('Audio/start.wav', SND_FILENAME | SND_ASYNC)
|
||||
|
||||
if event == self.gui_recenter_eyes:
|
||||
self.settings.gui_recenter_eyes = True
|
||||
|
||||
@ -3,7 +3,10 @@ from osc import EyeId
|
||||
import os.path
|
||||
import json
|
||||
from pydantic import BaseModel
|
||||
import shutil
|
||||
|
||||
CONFIG_FILE_NAME: str = "eyetrack_settings.json"
|
||||
BACKUP_CONFIG_FILE_NAME: str = "eyetrack_settings.backup"
|
||||
|
||||
|
||||
class EyeTrackCameraConfig(BaseModel):
|
||||
@ -61,9 +64,35 @@ class EyeTrackConfig(BaseModel):
|
||||
if not os.path.exists(CONFIG_FILE_NAME):
|
||||
print("No settings file, using base settings")
|
||||
return EyeTrackConfig()
|
||||
with open(CONFIG_FILE_NAME, "r") as settings_file:
|
||||
return EyeTrackConfig(**json.load(settings_file))
|
||||
try:
|
||||
with open(CONFIG_FILE_NAME, "r") as settings_file:
|
||||
return EyeTrackConfig(**json.load(settings_file))
|
||||
except json.JSONDecodeError:
|
||||
print("Failed to load settings file.")
|
||||
load_config = None
|
||||
if os.path.exists(BACKUP_CONFIG_FILE_NAME):
|
||||
try:
|
||||
with open(BACKUP_CONFIG_FILE_NAME, "r") as settings_file:
|
||||
load_config = EyeTrackConfig(**json.load(settings_file))
|
||||
print("using backup settings")
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
if load_config is None:
|
||||
print("using base settings")
|
||||
load_config = EyeTrackConfig()
|
||||
return load_config
|
||||
|
||||
def save(self):
|
||||
with open(CONFIG_FILE_NAME, "w+") as settings_file:
|
||||
# todo: Write only if there is a difference between the saved configuration file and the current configuration.
|
||||
if os.path.exists(CONFIG_FILE_NAME):
|
||||
try:
|
||||
# Verify existing configuration files.
|
||||
with open(CONFIG_FILE_NAME, "r") as settings_file:
|
||||
EyeTrackConfig(**json.load(settings_file))
|
||||
shutil.copy(CONFIG_FILE_NAME, BACKUP_CONFIG_FILE_NAME)
|
||||
# print("Backed up settings files.") # Comment out because it's too loud.
|
||||
except json.JSONDecodeError:
|
||||
# No backup because the saved settings file is broken.
|
||||
pass
|
||||
with open(CONFIG_FILE_NAME, "w") as settings_file:
|
||||
json.dump(obj=self.dict(), fp=settings_file)
|
||||
|
||||
@ -46,9 +46,7 @@ import numpy as np
|
||||
import cv2
|
||||
from enum import Enum
|
||||
from one_euro_filter import OneEuroFilter
|
||||
if sys.platform.startswith("win"):
|
||||
from winsound import PlaySound, SND_FILENAME, SND_ASYNC
|
||||
|
||||
from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC
|
||||
import importlib
|
||||
from osc_calibrate_filter import *
|
||||
from haar_surround_feature import External_Run_HSF
|
||||
@ -93,8 +91,7 @@ def run_once(f):
|
||||
async def delayed_setting_change(setting, value):
|
||||
await asyncio.sleep(5)
|
||||
setting = value
|
||||
if sys.platform.startswith("win"):
|
||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import os
|
||||
from utils.misc_utils import is_nt
|
||||
from osc import VRChatOSCReceiver, VRChatOSC, EyeId
|
||||
from config import EyeTrackConfig
|
||||
from camera_widget import CameraWidget
|
||||
from settings_widget import SettingsWidget
|
||||
|
||||
import queue
|
||||
import threading
|
||||
import PySimpleGUI as sg
|
||||
@ -11,8 +13,7 @@ import urllib.request
|
||||
|
||||
import webbrowser
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
from win10toast_click import ToastNotifier
|
||||
|
||||
|
||||
# Random environment variable to speed up webcam opening on the MSMF backend.
|
||||
# https://github.com/opencv/opencv/issues/17687
|
||||
@ -68,7 +69,8 @@ def main():
|
||||
else:
|
||||
print(
|
||||
f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m")
|
||||
if sys.platform.startswith("win"):
|
||||
if is_nt:
|
||||
from win10toast_click import ToastNotifier
|
||||
toaster = ToastNotifier()
|
||||
toaster.show_toast( # show windows toast
|
||||
"EyeTrackVR has an update.",
|
||||
|
||||
@ -3,8 +3,7 @@ from pythonosc import udp_client
|
||||
from pythonosc import osc_server
|
||||
from pythonosc import dispatcher
|
||||
import sys
|
||||
if sys.platform.startswith("win"):
|
||||
from winsound import PlaySound, SND_FILENAME, SND_ASYNC
|
||||
from utils.misc_utils import PlaySound,SND_FILENAME,SND_ASYNC
|
||||
import queue
|
||||
import threading
|
||||
from enum import IntEnum
|
||||
@ -179,8 +178,7 @@ class VRChatOSCReceiver:
|
||||
if osc_value:
|
||||
for eye in self.eyes:
|
||||
eye.ransac.calibration_frame_counter = 300
|
||||
if sys.platform.startswith("win"):
|
||||
PlaySound('Audio/start.wav', SND_FILENAME | SND_ASYNC)
|
||||
PlaySound('Audio/start.wav', SND_FILENAME | SND_ASYNC)
|
||||
|
||||
def run(self):
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import sys
|
||||
if sys.platform.startswith("win"):
|
||||
from winsound import PlaySound, SND_FILENAME, SND_ASYNC
|
||||
from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC
|
||||
import numpy as np
|
||||
|
||||
def cal_osc(self, cx, cy):
|
||||
@ -12,8 +11,7 @@ def cal_osc(self, cx, cy):
|
||||
self.calibration_frame_counter = None
|
||||
self.xoff = cx
|
||||
self.yoff = cy
|
||||
if sys.platform.startswith("win"):
|
||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||
elif self.calibration_frame_counter != None:
|
||||
self.settings.gui_recenter_eyes = False
|
||||
if cx > self.xmax:
|
||||
@ -30,8 +28,7 @@ def cal_osc(self, cx, cy):
|
||||
self.yoff = cy
|
||||
if self.ts == 0:
|
||||
self.settings.gui_recenter_eyes = False
|
||||
if sys.platform.startswith("win"):
|
||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
|
||||
else:
|
||||
self.ts = self.ts - 1
|
||||
else:
|
||||
|
||||
@ -1,2 +1,14 @@
|
||||
import os
|
||||
is_nt = True if os.name == "nt" else False
|
||||
|
||||
def PlaySound(*args, **kwargs): pass
|
||||
SND_FILENAME = SND_ASYNC = 1
|
||||
|
||||
if is_nt:
|
||||
import winsound
|
||||
PlaySound = winsound.PlaySound
|
||||
SND_FILENAME = winsound.SND_FILENAME
|
||||
SND_ASYNC = winsound.SND_ASYNC
|
||||
|
||||
def clamp(x, low, high):
|
||||
return max(low, min(x, high))
|
||||
return max(low, min(x, high))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user