Skip to content

Instantly share code, notes, and snippets.

@papr
Last active July 4, 2022 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papr/af39155d853528fb29cc38571c07287f to your computer and use it in GitHub Desktop.
Save papr/af39155d853528fb29cc38571c07287f to your computer and use it in GitHub Desktop.
Custom pye3d detector that exposes its internal settings as UI elements. For installation instructions, see https://docs.pupil-labs.com/developer/core/plugin-api/#adding-a-plugin
from pyglui import ui
from pupil_detector_plugins.pye3d_plugin import Pye3DPlugin
class CustomPye3DPlugin(Pye3DPlugin):
label = "Custom pye3d Detector"
order = 0.102
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._stop_other_pupil_detectors()
def _stop_other_pupil_detectors(self):
plugin_list = self.g_pool.plugins
# Deactivate other PupilDetectorPlugin instances
for plugin in plugin_list:
if isinstance(plugin, Pye3DPlugin) and plugin is not self:
plugin.alive = False
# Force Plugin_List to remove deactivated plugins
plugin_list.clean()
@classmethod
def parse_pretty_class_name(cls) -> str:
return cls.label
def init_ui(self):
super().init_ui()
self.menu.append(ui.Separator())
self.menu.append(ui.Info_Text("Custom 3d detector settings"))
def make_setter(name):
def _set(value):
self.detector._settings[name] = value
self.detector.reset()
return _set
for name in self.detector._settings:
self.menu.append(
ui.Text_Input(name, self.detector._settings, setter=make_setter(name))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment