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
|
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:
|
class Camera:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -126,7 +136,8 @@ class Camera:
|
|||||||
# than this, otherwise we can deadlock ourselves.
|
# than this, otherwise we can deadlock ourselves.
|
||||||
if self.config.capture_source != None and self.config.capture_source != "":
|
if self.config.capture_source != None and self.config.capture_source != "":
|
||||||
self.current_capture_source = 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 (
|
if (
|
||||||
self.serial_connection is None
|
self.serial_connection is None
|
||||||
or self.camera_status == CameraState.DISCONNECTED
|
or self.camera_status == CameraState.DISCONNECTED
|
||||||
@ -166,7 +177,8 @@ class Camera:
|
|||||||
if should_push and not self.capture_event.wait(timeout=0.001):
|
if should_push and not self.capture_event.wait(timeout=0.001):
|
||||||
continue
|
continue
|
||||||
if self.config.capture_source != None:
|
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)
|
self.get_serial_camera_picture(should_push)
|
||||||
else:
|
else:
|
||||||
self.get_cv2_camera_picture(should_push)
|
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):
|
if not any(p for p in com_ports if port in p):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
rate = 115200 if sys.platform == "darwin" else 3000000 # Higher baud rate not working on macOS
|
||||||
conn = serial.Serial(
|
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.
|
# 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(
|
print(f"{Fore.CYAN}[INFO] ETVR Serial Tracker device connected on {port}{Fore.RESET}")
|
||||||
f"{Fore.CYAN}[INFO] ETVR Serial Tracker device connected on {port}{Fore.RESET}"
|
|
||||||
)
|
|
||||||
self.serial_connection = conn
|
self.serial_connection = conn
|
||||||
self.camera_status = CameraState.CONNECTED
|
self.camera_status = CameraState.CONNECTED
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@ -317,6 +317,7 @@ class CameraWidget:
|
|||||||
len(values[self.gui_camera_addr]) > 5
|
len(values[self.gui_camera_addr]) > 5
|
||||||
and "http" not in values[self.gui_camera_addr]
|
and "http" not in values[self.gui_camera_addr]
|
||||||
and ".mp4" 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.
|
): # If http is not in camera address, add it.
|
||||||
self.config.capture_source = f"http://{values[self.gui_camera_addr]}/"
|
self.config.capture_source = f"http://{values[self.gui_camera_addr]}/"
|
||||||
else:
|
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"
|
requests = "^2.28.1"
|
||||||
opencv-python = "^4.6.0.66"
|
opencv-python = "^4.6.0.66"
|
||||||
numpy = "~1.23.5"
|
numpy = "~1.23.5"
|
||||||
pye3d = "^0.3.1.post1"
|
pye3d = "^0.3.2"
|
||||||
pysimplegui = "^4.60.4"
|
pysimplegui = "^4.59.0"
|
||||||
pydantic = "^2.4.2"
|
pydantic = "^2.4.2"
|
||||||
scikit-image = "*"
|
scikit-image = "*"
|
||||||
pyserial = "^3.5"
|
pyserial = "^3.5"
|
||||||
@ -25,6 +25,7 @@ colorama = "^0.4.6"
|
|||||||
taskipy = "^1.10.4"
|
taskipy = "^1.10.4"
|
||||||
pytest = "^8.0.0"
|
pytest = "^8.0.0"
|
||||||
pytest-cov = "^4.1.0"
|
pytest-cov = "^4.1.0"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
black = "^22.10.0"
|
black = "^22.10.0"
|
||||||
pyinstaller = "^5.6.2"
|
pyinstaller = "^5.6.2"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user