def init_ui(self): self.add_menu() pupil_producer_plugins = [p for p in self.g_pool.plugin_by_name.values() if issubclass(p, Pupil_Producer_Base)] pupil_producer_plugins.sort(key=lambda p: p.__name__) self.menu_icon.order = 0.29 def open_plugin(p): self.notify_all({'subject': 'start_plugin', 'name': p.__name__}) # We add the capture selection menu self.menu.append(ui.Selector( 'pupil_producer', setter=open_plugin, getter=lambda: self.__class__, selection=pupil_producer_plugins, labels=[p.__name__.replace('_', ' ') for p in pupil_producer_plugins], label='Pupil Producers' )) self.glfont = fs.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_font('opensans') self.dia_timeline = ui.Timeline('Pupil Diameter [px]', self.draw_pupil_diameter, self.draw_dia_legend) self.conf_timeline = ui.Timeline('Pupil Confidence', self.draw_pupil_conf, self.draw_conf_legend) self.g_pool.user_timelines.append(self.dia_timeline) self.g_pool.user_timelines.append(self.conf_timeline)
def init_ui(self): self.add_menu() pupil_producer_plugins = [ p for p in self.g_pool.plugin_by_name.values() if issubclass(p, Pupil_Producer_Base) ] pupil_producer_plugins.sort( key=lambda p: p.pupil_data_source_selection_label()) pupil_producer_plugins.sort( key=lambda p: p.pupil_data_source_selection_order()) pupil_producer_labels = [ p.pupil_data_source_selection_label() for p in pupil_producer_plugins ] self.menu.label = self.plugin_menu_label() self.menu_icon.order = 0.29 self.menu_icon.tooltip = "Pupil Data" def open_plugin(p): self.notify_all({"subject": "start_plugin", "name": p.__name__}) # We add the capture selection menu self.menu.append( ui.Selector( "pupil_producer", setter=open_plugin, getter=lambda: self.__class__, selection=pupil_producer_plugins, labels=pupil_producer_labels, label="Data Source", )) self.cache = {} self.cache_pupil_timeline_data(DATA_KEY_DIAMETER, detector_tag="3d") self.cache_pupil_timeline_data( DATA_KEY_CONFIDENCE, detector_tag="2d", ylim=(0.0, 1.0), fallback_detector_tag="3d", ) self.glfont = fs.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_font("opensans") self.dia_timeline = ui.Timeline( label="Pupil Diameter 3D", draw_data_callback=self.draw_pupil_diameter, draw_label_callback=self.draw_dia_legend, content_height=40.0, ) self.conf_timeline = ui.Timeline("Pupil Confidence", self.draw_pupil_conf, self.draw_conf_legend) self.g_pool.user_timelines.append(self.dia_timeline) self.g_pool.user_timelines.append(self.conf_timeline)
def init_ui(self): if self.pa_stream is None: return self.add_menu() self.menu_icon.order = 0.01 self.menu.label = "Audio Playback" def set_volume(val): self.req_audio_volume = val self.menu.append( ui.Slider( "req_audio_volume", self, step=0.05, min=0.0, max=1.0, label="Volume", ) ) self.menu.append( ui.Slider( "req_buffer_size_secs", self, step=0.05, min=0.0, max=1.0, label="Buffer size (s)", ) ) self.audio_timeline = ui.Timeline("Audio level", self.draw_audio, None) self.audio_timeline.content_height *= 2 self.g_pool.user_timelines.append(self.audio_timeline) self.menu.append(ui.Switch("log_scale", self, label="Log scale"))
def set_timeline(self, x, y, xlim, ylim, glfont): self.x = x self.y = y self.xlim = xlim self.ylim = ylim self.glfont = glfont return ui.Timeline("EEG", self.draw_data, self.draw_legend)
def init_ui(self): self.glfont = fs.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_font('opensans') self.fps_timeline = ui.Timeline('Recorded FPS', self.draw_fps, self.draw_fps_legend) self.fps_timeline.content_height *= 2 self.g_pool.user_timelines.append(self.fps_timeline)
def append_timeline_raw(self): self.gyro_timeline = ui.Timeline( "gyro", self.draw_raw_gyro, self.draw_legend_gyro, self.TIMELINE_LINE_HEIGHT * 3, ) self.accel_timeline = ui.Timeline( "accel", self.draw_raw_accel, self.draw_legend_accel, self.TIMELINE_LINE_HEIGHT * 3, ) self.g_pool.user_timelines.append(self.gyro_timeline) self.g_pool.user_timelines.append(self.accel_timeline) self.glfont_raw = glfont_generator()
def init_ui(self): self.add_menu() self.menu.label = "Offline Surface Tracker" self.add_button = ui.Thumb( "add_surface", setter=lambda x: self.add_surface(), getter=lambda: False, label="A", hotkey="a", ) self.g_pool.quickbar.append(self.add_button) self.glfont = fontstash.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_color_float((1.0, 1.0, 1.0, 0.8)) self.glfont.set_align_string(v_align="right", h_align="top") self.timeline = ui.Timeline( "Surface Tracker", self.gl_display_cache_bars, self.draw_labels, self.timeline_line_height * (len(self.surfaces) + 1), ) self.g_pool.user_timelines.append(self.timeline) self.update_gui_markers()
def init_ui(self): if self.pa_stream is None: return self.add_menu() self.menu_icon.order = 0.01 self.menu.label = 'Audio Playback' def set_volume(val): #print("set_volume!") self.req_audio_volume = val self.menu.append( ui.Slider( 'req_audio_volume', self, #setter=set_volume, step=.05, min=0.0, max=1.0, label='Volume')) self.menu.append( ui.Slider( 'req_buffer_size_secs', self, # setter=set_volume, step=.05, min=0.0, max=1.0, label='Buffer size (s)')) self.audio_timeline = ui.Timeline('Audio level', self.draw_audio, None) self.audio_timeline.content_height *= 2 self.g_pool.user_timelines.append(self.audio_timeline) self.menu.append(ui.Switch('log_scale', self, label='Log scale'))
def init_ui(self): super().init_ui() self.glfont = fs.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_font('opensans') self.timeline = ui.Timeline('Blink Detection', self.draw_activation, self.draw_legend) self.timeline.content_height *= 2 self.g_pool.user_timelines.append(self.timeline)
def init_ui(self): super().init_ui() self.menu.label = "Offline Calibration" self.glfont = fontstash.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_color_float((1., 1., 1., 1.)) self.glfont.set_align_string(v_align='right', h_align='top') def use_as_natural_features(): self.manual_ref_positions.extend(self.circle_marker_positions) self.manual_ref_positions.sort(key=lambda mr: mr['index']) def jump_next_natural_feature(): self.manual_ref_positions.sort(key=lambda mr: mr['index']) current = self.g_pool.capture.get_frame_index() for nf in self.manual_ref_positions: if nf['index'] > current: self.notify_all({'subject': 'seek_control.should_seek', 'index': nf['index']}) return logger.error('No further natural feature available') def clear_natural_features(): self.manual_ref_positions = [] self.menu.append(ui.Info_Text('"Detection" searches for circle markers in the world video.')) # self.menu.append(ui.Button('Redetect', self.start_marker_detection)) slider = ui.Slider('detection_progress', self, label='Detection Progress', setter=lambda _: _) slider.display_format = '%3.0f%%' self.menu.append(slider) toggle_label = 'Cancel circle marker detection' if self.process_pipe else 'Start circle marker detection' self.toggle_detection_button = ui.Button(toggle_label, self.toggle_marker_detection) self.menu.append(self.toggle_detection_button) self.menu.append(ui.Separator()) self.menu.append(ui.Button('Use calibration markers as natural features', use_as_natural_features)) self.menu.append(ui.Button('Jump to next natural feature', jump_next_natural_feature)) self.menu.append(ui.Switch('manual_ref_edit_mode', self, label="Natural feature edit mode")) self.menu.append(ui.Button('Clear natural features', clear_natural_features)) self.menu.append(ui.Info_Text('Calibration only considers pupil data that has an equal or higher confidence than the minimum calibration confidence.')) self.menu.append(ui.Slider('min_calibration_confidence', self.g_pool, step=.01, min=0.0, max=1.0, label='Minimum calibration confidence')) self.menu.append(ui.Button('Add section', self.append_section)) # set to minimum height self.timeline = ui.Timeline('Calibration Sections', self.draw_sections, self.draw_labels, 1) self.g_pool.user_timelines.append(self.timeline) for sec in self.sections: self.append_section_menu(sec) self.on_window_resize(glfw.glfwGetCurrentContext(), *glfw.glfwGetWindowSize(glfw.glfwGetCurrentContext()))
def append_timeline_orientation(self): self.orient_timeline = ui.Timeline( "orientation", self.draw_orient, self.draw_legend_orient, self.TIMELINE_LINE_HEIGHT * 2, ) self.g_pool.user_timelines.append(self.orient_timeline) self.glfont_orient = glfont_generator()
def init_ui(self): self.add_menu() pupil_producer_plugins = [ p for p in self.g_pool.plugin_by_name.values() if issubclass(p, Pupil_Producer_Base) ] pupil_producer_plugins.sort(key=lambda p: p.__name__) self.menu_icon.order = 0.29 def open_plugin(p): self.notify_all({"subject": "start_plugin", "name": p.__name__}) # We add the capture selection menu self.menu.append( ui.Selector( "pupil_producer", setter=open_plugin, getter=lambda: self.__class__, selection=pupil_producer_plugins, labels=[ p.__name__.replace("_", " ") for p in pupil_producer_plugins ], label="Pupil Producers", )) self.cache = {} self.cache_pupil_timeline_data("diameter") self.cache_pupil_timeline_data("confidence") self.glfont = fs.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_font("opensans") self.dia_timeline = ui.Timeline("Pupil Diameter [px]", self.draw_pupil_diameter, self.draw_dia_legend) self.conf_timeline = ui.Timeline("Pupil Confidence", self.draw_pupil_conf, self.draw_conf_legend) self.g_pool.user_timelines.append(self.dia_timeline) self.g_pool.user_timelines.append(self.conf_timeline)
def init_ui(self): super().init_ui() self.menu.label = "Offline Calibration" self.glfont = fontstash.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_color_float((1., 1., 1., .8)) self.glfont.set_align_string(v_align='right', h_align='top') def jump_next_natural_feature(): self.manual_ref_positions.sort(key=lambda mr: mr['index']) current = self.g_pool.capture.get_frame_index() for nf in self.manual_ref_positions: if nf['index'] > current: self.g_pool.capture.seek_to_frame(nf['index']) self.g_pool.new_seek = True return logger.error('No further natural feature available') def clear_natural_features(): self.manual_ref_positions = [] self.menu.append( ui.Info_Text( '"Detection" searches for calibration markers in the world video.' )) # self.menu.append(ui.Button('Redetect', self.start_detection_task)) slider = ui.Slider('detection_progress', self, label='Detection Progress', setter=lambda _: _) slider.display_format = '%3.0f%%' self.menu.append(slider) self.menu.append( ui.Button('Jump to next natural feature', jump_next_natural_feature)) self.menu.append( ui.Switch('manual_ref_edit_mode', self, label="Natural feature edit mode")) self.menu.append( ui.Button('Clear natural features', clear_natural_features)) self.menu.append(ui.Button('Add section', self.append_section)) # set to minimum height self.timeline = ui.Timeline('Calibration Sections', self.draw_sections, self.draw_labels, 1) self.g_pool.user_timelines.append(self.timeline) for sec in self.sections: self.append_section_menu(sec) self.on_window_resize(glfwGetCurrentContext(), *glfwGetWindowSize(glfwGetCurrentContext()))
def init_ui(self): self.add_menu() self.menu.label = 'Offline Surface Tracker' self.add_button = ui.Thumb('add_surface',setter=lambda x: self.add_surface(),getter=lambda:False,label='A',hotkey='a') self.g_pool.quickbar.append(self.add_button) self.glfont = fontstash.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_color_float((1., 1., 1., .8)) self.glfont.set_align_string(v_align='right', h_align='top') self.timeline = ui.Timeline('Surface Tracker', self.gl_display_cache_bars, self.draw_labels, self.timeline_line_height * (len(self.surfaces) + 1)) self.g_pool.user_timelines.append(self.timeline) self.update_gui_markers()
def __init__(self, plugin, title, timeline_ui_parent, all_timestamps): self._timeline_ui_parent = timeline_ui_parent self._all_timestamps = all_timestamps self._time_start = all_timestamps[0] self._time_end = all_timestamps[-1] self._rows = [] # initially set to minimum height self._timeline = ui.Timeline( title, self.draw_sections, self.draw_labels, content_height=1 ) self.glfont = fontstash.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_color_float((1.0, 1.0, 1.0, 1.0)) self.glfont.set_align_string(v_align="right", h_align="top") plugin.add_observer("init_ui", self._on_init_ui) plugin.add_observer("deinit_ui", self._on_deinit_ui)
def init_ui(self): super().init_ui() self.timeline = ui.Timeline('Blink Detection', self.draw_activation) self.g_pool.user_timelines.append(self.timeline)