mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
feat: MacOS support
This commit is contained in:
parent
5e4bfadffa
commit
30b8ac46ce
@ -67,6 +67,16 @@ class CameraState(Enum):
|
||||
DISCONNECTED = 2
|
||||
|
||||
|
||||
def is_serial_capture_source(addr: str) -> bool:
|
||||
"""
|
||||
Returns True if the capture source address is a serial port.
|
||||
"""
|
||||
return (addr.startswith("COM") # Windows
|
||||
or addr.startswith("/dev/cu") # macOS
|
||||
or addr.startswith("/dev/tty") # Linux
|
||||
)
|
||||
|
||||
|
||||
class Camera:
|
||||
def __init__(
|
||||
self,
|
||||
@ -126,7 +136,8 @@ class Camera:
|
||||
# than this, otherwise we can deadlock ourselves.
|
||||
if self.config.capture_source != None and self.config.capture_source != "":
|
||||
self.current_capture_source = self.config.capture_source
|
||||
if "COM" in str(self.current_capture_source):
|
||||
addr = str(self.current_capture_source)
|
||||
if is_serial_capture_source(addr):
|
||||
if (
|
||||
self.serial_connection is None
|
||||
or self.camera_status == CameraState.DISCONNECTED
|
||||
@ -166,7 +177,8 @@ class Camera:
|
||||
if should_push and not self.capture_event.wait(timeout=0.001):
|
||||
continue
|
||||
if self.config.capture_source != None:
|
||||
if "COM" in str(self.current_capture_source):
|
||||
addr = str(self.current_capture_source)
|
||||
if is_serial_capture_source(addr):
|
||||
self.get_serial_camera_picture(should_push)
|
||||
else:
|
||||
self.get_cv2_camera_picture(should_push)
|
||||
@ -301,15 +313,16 @@ class Camera:
|
||||
if not any(p for p in com_ports if port in p):
|
||||
return
|
||||
try:
|
||||
rate = 115200 if sys.platform == "darwin" else 3000000 # Higher baud rate not working on macOS
|
||||
conn = serial.Serial(
|
||||
baudrate=3000000, port=port, xonxoff=False, dsrdtr=False, rtscts=False
|
||||
baudrate=rate, port=port, xonxoff=False, dsrdtr=False, rtscts=False
|
||||
)
|
||||
# Set explicit buffer size for serial.
|
||||
conn.set_buffer_size(rx_size=32768, tx_size=32768)
|
||||
if sys.platform == "win32":
|
||||
buffer_size = 32768
|
||||
conn.set_buffer_size(rx_size=buffer_size, tx_size=buffer_size)
|
||||
|
||||
print(
|
||||
f"{Fore.CYAN}[INFO] ETVR Serial Tracker device connected on {port}{Fore.RESET}"
|
||||
)
|
||||
print(f"{Fore.CYAN}[INFO] ETVR Serial Tracker device connected on {port}{Fore.RESET}")
|
||||
self.serial_connection = conn
|
||||
self.camera_status = CameraState.CONNECTED
|
||||
except Exception:
|
||||
|
||||
@ -317,6 +317,7 @@ class CameraWidget:
|
||||
len(values[self.gui_camera_addr]) > 5
|
||||
and "http" not in values[self.gui_camera_addr]
|
||||
and ".mp4" not in values[self.gui_camera_addr]
|
||||
and not values[self.gui_camera_addr].startswith('/dev') # For MacOS and Linux users
|
||||
): # If http is not in camera address, add it.
|
||||
self.config.capture_source = f"http://{values[self.gui_camera_addr]}/"
|
||||
else:
|
||||
|
||||
954
poetry.lock
generated
954
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,8 @@ python-osc = "^1.8.0"
|
||||
requests = "^2.28.1"
|
||||
opencv-python = "^4.6.0.66"
|
||||
numpy = "~1.23.5"
|
||||
pye3d = "^0.3.1.post1"
|
||||
pysimplegui = "^4.60.4"
|
||||
pye3d = "^0.3.2"
|
||||
pysimplegui = "^4.59.0"
|
||||
pydantic = "^2.4.2"
|
||||
scikit-image = "*"
|
||||
pyserial = "^3.5"
|
||||
@ -25,6 +25,7 @@ colorama = "^0.4.6"
|
||||
taskipy = "^1.10.4"
|
||||
pytest = "^8.0.0"
|
||||
pytest-cov = "^4.1.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^22.10.0"
|
||||
pyinstaller = "^5.6.2"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user