Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Neon support to Pupil Service #2306

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pupil_src/launchables/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def stop_eye_process(eye_id):
from service_ui import Service_UI
from uvc import get_time_monotonic
from version_utils import parse_version
from video_capture.neon_backend.plugin import Neon_Manager

IPC_Logging_Task_Proxy.push_url = ipc_push_url

Expand Down Expand Up @@ -158,6 +159,7 @@ def get_timestamp():
Pupil_Groups,
NetworkApiPlugin,
Blink_Detection,
Neon_Manager,
] + runtime_plugins
plugin_by_index = (
runtime_plugins
Expand All @@ -169,6 +171,7 @@ def get_timestamp():
plugin_by_name = dict(zip(name_by_index, plugin_by_index))
default_plugins = [
("Service_UI", {}),
("Neon_Manager", {}),
# Calibration choreography plugin is added bellow by calling
# patch_world_session_settings_with_choreography_plugin
("NetworkApiPlugin", {}),
Expand Down
18 changes: 18 additions & 0 deletions pupil_src/shared_modules/service_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from plugin import System_Plugin_Base
from pyglui import cygl, ui
from video_capture.neon_backend.plugin import Neon_Manager

# UI Platform tweaks
if platform.system() == "Linux":
Expand Down Expand Up @@ -170,6 +171,23 @@ def reset_restart():
getter=lambda: g_pool.eye_procs_alive[1].value,
)
)
g_pool.menubar.append(
ui.Info_Text(
"To use Neon, connect it to your PC and click the button below."
)
)
g_pool.menubar.append(
ui.Button(
"Activate Neon",
lambda: self.notify_all(
{
"subject": Neon_Manager.SUBJECT_REQUEST_AUTO_ACTIVATE,
"scene": False,
"eyes": True,
}
),
)
)

g_pool.menubar.append(ui.Info_Text(f"Service Version: {g_pool.version}"))

Expand Down
28 changes: 18 additions & 10 deletions pupil_src/shared_modules/video_capture/neon_backend/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class Neon_Manager(Base_Manager):
SUBJECT_REQUEST_SHARED_CAMERA_START: str = "neon_backend.shared_camera.should_start"
SUBJECT_REQUEST_AUTO_ACTIVATE: str = "neon_backend.auto_activate"

def __init__(self, g_pool):
super().__init__(g_pool)
Expand Down Expand Up @@ -58,7 +59,7 @@ def activate(self, key: Any) -> None:
if key == "neon":
self.auto_activate_source()

def auto_activate_source(self):
def auto_activate_source(self, scene: bool = True, eyes: bool = True):
logger.debug("Auto activating Neon source.")

# self.enable_neon_eye_camera_sharing()
Expand All @@ -72,21 +73,28 @@ def auto_activate_source(self):
"uid": source_uid,
"name": "Neon Scene Camera v1",
}
self.notify_all(
{"subject": "start_plugin", "name": "UVC_Source", "args": settings}
)
for eye in range(2):
if scene:
self.notify_all(
{
"subject": "start_eye_plugin",
"target": f"eye{eye}",
"name": "Neon_Eye_Cam_Source",
}
{"subject": "start_plugin", "name": "UVC_Source", "args": settings}
)
if eyes:
for eye in range(2):
self.notify_all(
{
"subject": "start_eye_plugin",
"target": f"eye{eye}",
"name": "Neon_Eye_Cam_Source",
}
)

def on_notify(self, notification):
if notification["subject"] == self.SUBJECT_REQUEST_SHARED_CAMERA_START:
self.enable_neon_eye_camera_sharing()
elif notification["subject"] == self.SUBJECT_REQUEST_AUTO_ACTIVATE:
self.auto_activate_source(
scene=notification.get("scene", True),
eyes=notification.get("eyes", True),
)
return super().on_notify(notification)

def enable_neon_eye_camera_sharing(self):
Expand Down